Skip to content

Commit 4bddc30

Browse files
committed
less duplicate code in hide functions
1 parent 8970805 commit 4bddc30

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/main/kotlin/com/lambda/config/AutomationConfig.kt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,8 @@ open class AutomationConfig(
145145
) = TypedEditBuilder(this@AutomationConfig, settings.map { it.delegate } as List<AbstractSetting<T>>).edits(other.delegate as AbstractSetting<R>)
146146

147147
@SettingEditorDsl
148-
fun hide(vararg settings: KProperty0<*>) = {
149-
(settings.map { it.delegate } as List<AbstractSetting<*>>).let { removed ->
150-
this@AutomationConfig.settings.removeAll(removed)
151-
hiddenSettings.addAll(removed)
152-
}
148+
fun hide(vararg settings: KProperty0<*>) {
149+
hideAll((settings.map { it.delegate } as List<AbstractSetting<*>>))
153150
}
154151

155152
@SettingEditorDsl
@@ -163,10 +160,7 @@ open class AutomationConfig(
163160

164161
@SettingEditorDsl
165162
fun hideAll(vararg settingGroups: SettingGroup) {
166-
settingGroups.flatMap { it.settings }.let { removed ->
167-
settings.removeAll(removed)
168-
hiddenSettings.addAll(removed)
169-
}
163+
settingGroups.forEach { hideAll(it.settings) }
170164
}
171165

172166
@SettingEditorDsl

0 commit comments

Comments
 (0)