[FIR] Extend capacity of ArrayMapImpl until it fits required size
There are cases when we have some indices in TypeRegistry left from previous compilations, so registering new service may increase index not by one So such situation is possible: First compilation (jvm project): register 20 different jvm services in session + one from compiler plugin (with index 21) Second compilation (common project): register only 10 common services in session + one from compiler plugin (with index 21) *numbers are imaginary And in this situation increasing `ArrayMapImpl.data` size only one time may not cover required index ^KT-56685 Fixed
This commit is contained in:
committed by
Space Team
parent
27db8ce1bb
commit
bdf8e6f3a5
@@ -87,9 +87,12 @@ internal class ArrayMapImpl<T : Any> 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) {
|
||||
|
||||
Reference in New Issue
Block a user