Do not use indexed access for lists not supporting RandomAccess
Add RandomAccess specialization.
This commit is contained in:
@@ -550,8 +550,12 @@ public fun <T> Iterable<T>.drop(n: Int): List<T> {
|
||||
return emptyList()
|
||||
list = ArrayList<T>(resultSize)
|
||||
if (this is List<T>) {
|
||||
for (item in listIterator(n)) {
|
||||
list.add(item)
|
||||
if (this is RandomAccess) {
|
||||
for (index in n..size - 1)
|
||||
list.add(this[index])
|
||||
} else {
|
||||
for (item in listIterator(n))
|
||||
list.add(item)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user