[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 {
|
fun hasModifier(modifier: String): Boolean {
|
||||||
modifiersMapReference.get()[modifier]?.let { return it }
|
modifiersMapReference.get()[modifier]?.let { return it }
|
||||||
val newValues = computer(modifier) ?: mapOf(modifier to false)
|
val newValues = computer(modifier) ?: mapOf(modifier to false)
|
||||||
do {
|
modifiersMapReference.updateAndGet {
|
||||||
val currentMap = modifiersMapReference.get()
|
it.putAll(newValues)
|
||||||
val newMap = currentMap.putAll(newValues)
|
}
|
||||||
} while (!modifiersMapReference.compareAndSet(currentMap, newMap))
|
|
||||||
|
|
||||||
return newValues[modifier] ?: error("Inconsistent state: $modifier")
|
return newValues[modifier] ?: error("Inconsistent state: $modifier")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user