FirResolution: store enabled value in field with initial reading from component

Before this commit, we read/wrote 'enabled' directly from PropertiesComponent.
Now we do only initial reading and then store modified value in field.
This should make 'enabled' reading faster.
This commit is contained in:
Mikhail Glukhikh
2019-12-09 12:40:10 +03:00
parent 0d2d76696c
commit 809b7d8381
@@ -12,9 +12,16 @@ object FirResolution {
private const val ENABLED_BY_DEFAULT = false
private const val optionName = "kotlin.use.fir.resolution"
private val initialEnabledValue: Boolean by lazy {
PropertiesComponent.getInstance().getBoolean(optionName, ENABLED_BY_DEFAULT)
}
private var changedEnabledValue: Boolean? = null
var enabled: Boolean
get() = PropertiesComponent.getInstance().getBoolean(optionName, ENABLED_BY_DEFAULT)
get() = changedEnabledValue ?: initialEnabledValue
set(value) {
PropertiesComponent.getInstance().setValue(optionName, value, ENABLED_BY_DEFAULT)
changedEnabledValue = value
//PropertiesComponent.getInstance().setValue(optionName, value, ENABLED_BY_DEFAULT)
}
}