Implement optimized removeRange for ArrayDeque #KT-64956
Test ArrayDeque with size 15. With the existing sizes the removeRange implementation couldn't reach the maximum number of iterations - 3. Benchmark results for ArrayDeque.subList().clear() that uses removeRange() can be found here: https://github.com/qurbonzoda/KotlinArrayDequeBenchmarks/tree/master/results
This commit is contained in:
committed by
Space Team
parent
240a423bed
commit
b67ebf36a2
@@ -221,6 +221,13 @@ public actual abstract class AbstractMutableList<E> protected actual constructor
|
||||
return list.set(fromIndex + index, element)
|
||||
}
|
||||
|
||||
override fun removeRange(fromIndex: Int, toIndex: Int) {
|
||||
checkForComodification()
|
||||
list.removeRange(this.fromIndex + fromIndex, this.fromIndex + toIndex)
|
||||
_size -= toIndex - fromIndex
|
||||
modCount = list.modCount
|
||||
}
|
||||
|
||||
override val size: Int
|
||||
get() {
|
||||
checkForComodification()
|
||||
|
||||
Reference in New Issue
Block a user