diff --git a/runtime/src/main/kotlin/kotlin/collections/ArrayList.kt b/runtime/src/main/kotlin/kotlin/collections/ArrayList.kt index bdde9865883..f6d0b72bcb3 100644 --- a/runtime/src/main/kotlin/kotlin/collections/ArrayList.kt +++ b/runtime/src/main/kotlin/kotlin/collections/ArrayList.kt @@ -200,7 +200,7 @@ actual class ArrayList private constructor( private fun insertAtInternal(i: Int, n: Int) { ensureExtraCapacity(n) - array.copyRange(fromIndex = i, toIndex = offset + length, destinationIndex = i + n) + array.copyRangeTo(array, fromIndex = i, toIndex = offset + length, destinationIndex = i + n) length += n } @@ -238,7 +238,7 @@ actual class ArrayList private constructor( return old } else { val old = array[i] - array.copyRange(fromIndex = i + 1, toIndex = offset + length, destinationIndex = i) + array.copyRangeTo(array, fromIndex = i + 1, toIndex = offset + length, destinationIndex = i) array.resetAt(offset + length - 1) length-- return old @@ -249,7 +249,7 @@ actual class ArrayList private constructor( if (backing != null) { backing.removeRangeInternal(rangeOffset, rangeLength) } else { - array.copyRange(fromIndex = rangeOffset + rangeLength, toIndex = length, destinationIndex = rangeOffset) + array.copyRangeTo(array, fromIndex = rangeOffset + rangeLength, toIndex = length, destinationIndex = rangeOffset) array.resetRange(fromIndex = length - rangeLength, toIndex = length) } length -= rangeLength @@ -272,7 +272,7 @@ actual class ArrayList private constructor( } } val removed = rangeLength - j - array.copyRange(fromIndex = rangeOffset + rangeLength, toIndex = length, destinationIndex = rangeOffset + j) + array.copyRangeTo(array, fromIndex = rangeOffset + rangeLength, toIndex = length, destinationIndex = rangeOffset + j) array.resetRange(fromIndex = length - removed, toIndex = length) length -= removed return removed diff --git a/runtime/src/main/kotlin/kotlin/collections/ArrayUtil.kt b/runtime/src/main/kotlin/kotlin/collections/ArrayUtil.kt index 25f6e28b9ac..a0f580b30f5 100644 --- a/runtime/src/main/kotlin/kotlin/collections/ArrayUtil.kt +++ b/runtime/src/main/kotlin/kotlin/collections/ArrayUtil.kt @@ -359,13 +359,6 @@ internal fun DoubleArray.copyRangeTo(destination: DoubleArray, fromIndex: Int, t internal fun BooleanArray.copyRangeTo(destination: BooleanArray, fromIndex: Int, toIndex: Int, destinationIndex: Int = 0) { copyImpl(this, fromIndex, destination, destinationIndex, toIndex - fromIndex) } -/** - * Copies a range of array elements at a specified [fromIndex] (inclusive) to [toIndex] (exclusive) range of indices - * to another part of this array starting at [destinationIndex]. - */ -public fun Array.copyRange(fromIndex: Int, toIndex: Int, destinationIndex: Int = 0) { - copyRangeTo(this, fromIndex, toIndex, destinationIndex) -} internal fun Collection.collectionToString(): String { val sb = StringBuilder(2 + size * 3)