[SLC] introduce SimpleModifiersBox
^KT-56046
This commit is contained in:
committed by
Space Team
parent
c401cd3210
commit
eaf6798684
+2
-2
@@ -24,10 +24,10 @@ internal typealias LazyModifiersComputer = (modifier: String) -> Map<String, Boo
|
||||
internal class LazyModifiersBox(
|
||||
initialValue: Map<String, Boolean>,
|
||||
private val computer: LazyModifiersComputer,
|
||||
) {
|
||||
) : ModifiersBox {
|
||||
private val modifiersMapReference: AtomicReference<PersistentMap<String, Boolean>> = AtomicReference(initialValue.toPersistentHashMap())
|
||||
|
||||
fun hasModifier(modifier: String): Boolean {
|
||||
override fun hasModifier(modifier: String): Boolean {
|
||||
modifiersMapReference.get()[modifier]?.let { return it }
|
||||
val newValues = computer(modifier) ?: mapOf(modifier to false)
|
||||
modifiersMapReference.updateAndGet {
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.light.classes.symbol.modifierLists
|
||||
|
||||
internal sealed interface ModifiersBox {
|
||||
fun hasModifier(modifier: String): Boolean
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.light.classes.symbol.modifierLists
|
||||
|
||||
internal class SimpleModifiersBox(private val modifiers: Set<String>) : ModifiersBox {
|
||||
override fun hasModifier(modifier: String): Boolean = modifier in modifiers
|
||||
}
|
||||
Reference in New Issue
Block a user