[SLC] SymbolLightModifierList: replace custom loop with compareAndSet with updateAndGet
^KTIJ-23783
This commit is contained in:
committed by
Space Team
parent
3ee451c873
commit
8a9acfcab0
+3
-4
@@ -97,10 +97,9 @@ internal class LazyModifiersBox(
|
||||
fun hasModifier(modifier: String): Boolean {
|
||||
modifiersMapReference.get()[modifier]?.let { return it }
|
||||
val newValues = computer(modifier) ?: mapOf(modifier to false)
|
||||
do {
|
||||
val currentMap = modifiersMapReference.get()
|
||||
val newMap = currentMap.putAll(newValues)
|
||||
} while (!modifiersMapReference.compareAndSet(currentMap, newMap))
|
||||
modifiersMapReference.updateAndGet {
|
||||
it.putAll(newValues)
|
||||
}
|
||||
|
||||
return newValues[modifier] ?: error("Inconsistent state: $modifier")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user