Do not use indexed access for lists not supporting RandomAccess

Add RandomAccess specialization.
This commit is contained in:
Ilya Gorbunov
2016-04-22 20:54:40 +03:00
parent f4f82656f7
commit 09c1ff1233
3 changed files with 15 additions and 4 deletions
@@ -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
}