diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/utils/ArrayMapOwner.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/utils/ArrayMapOwner.kt index 425471e99cf..e79a740aa03 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/utils/ArrayMapOwner.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/utils/ArrayMapOwner.kt @@ -6,6 +6,8 @@ package org.jetbrains.kotlin.fir.utils import java.util.* +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.atomic.AtomicInteger import kotlin.properties.ReadOnlyProperty import kotlin.reflect.KClass import kotlin.reflect.KProperty @@ -52,7 +54,9 @@ class NullableArrayMapAccessor( } abstract class TypeRegistry { - private val idPerType = HashMap, Int>() + private val idPerType = ConcurrentHashMap, Int>() + private val idCounter = AtomicInteger(0) + fun generateAccessor(kClass: KClass): ArrayMapAccessor { return ArrayMapAccessor(kClass, getId(kClass)) @@ -63,7 +67,7 @@ abstract class TypeRegistry { } fun getId(kClass: KClass): Int { - return idPerType.getOrPut(kClass) { idPerType.size } + return idPerType.computeIfAbsent(kClass) { idCounter.getAndIncrement() } } protected val indices: Collection