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
@@ -203,6 +203,11 @@ public actual abstract class AbstractMutableList<E> protected actual constructor
|
||||
return list.set(fromIndex + index, element)
|
||||
}
|
||||
|
||||
override fun removeRange(fromIndex: Int, toIndex: Int) {
|
||||
list.removeRange(this.fromIndex + fromIndex, this.fromIndex + toIndex)
|
||||
_size -= toIndex - fromIndex
|
||||
}
|
||||
|
||||
override val size: Int get() = _size
|
||||
|
||||
internal override fun checkIsMutable(): Unit = list.checkIsMutable()
|
||||
|
||||
Reference in New Issue
Block a user