Simplify state modification check (avoid an allocation in regular event)
authorVitaliy.Bibaev <vitaliy.bibaev@jetbrains.com>
Thu, 23 Nov 2017 10:37:22 +0000 (13:37 +0300)
committerVitaliy.Bibaev <vitaliy.bibaev@jetbrains.com>
Tue, 19 Dec 2017 08:31:40 +0000 (11:31 +0300)
plugins/stats-collector/src/com/intellij/plugin/Settings.kt

index 3f56c6fdf456ef03dfdac340144a55e9ce84d7df..94c5aa16a2e0949dffcae3a4a6d59da7e4eb1c68 100644 (file)
@@ -45,16 +45,9 @@ class PluginSettingsConfigurable : Configurable {
     private lateinit var manualSortingCb: JBCheckBox
 
     override fun isModified(): Boolean {
-        val isModifiedStates = mutableListOf<Boolean>()
-        isModifiedStates +=
-                manualControlCb.isSelected != ManualExperimentControl.isOn
-        
-        if (manualControlCb.isSelected) {
-            isModifiedStates +=
-                    manualSortingCb.isSelected != ManualMlSorting.isOn
-        }
-        
-        return isModifiedStates.contains(true)
+        val manualControlEnabled = manualControlCb.isSelected
+        return manualControlEnabled != ManualExperimentControl.isOn ||
+                (manualControlEnabled && manualSortingCb.isSelected != ManualMlSorting.isOn)
     }
 
     override fun getDisplayName() = "Completion Stats Collector"