diff --git a/core/compiler.common/src/org/jetbrains/kotlin/util/ArrayMap.kt b/core/compiler.common/src/org/jetbrains/kotlin/util/ArrayMap.kt index 1feab358db5..63434ab2e80 100644 --- a/core/compiler.common/src/org/jetbrains/kotlin/util/ArrayMap.kt +++ b/core/compiler.common/src/org/jetbrains/kotlin/util/ArrayMap.kt @@ -87,9 +87,12 @@ internal class ArrayMapImpl private constructor( private fun ensureCapacity(index: Int) { - if (data.size <= index) { - data = data.copyOf(data.size * INCREASE_K) - } + if (data.size > index) return + var newSize = data.size + do { + newSize *= INCREASE_K + } while (newSize <= index) + data = data.copyOf(newSize) } override operator fun set(index: Int, value: T) {