Move copyToArrayImpl implementation to Common source set
This commit is contained in:
committed by
Space Team
parent
6fdfd4e8dd
commit
7010bf2c20
@@ -22,17 +22,4 @@ internal fun <T> copyToArray(collection: Collection<T>): Array<T> =
|
||||
//TODO: Find more proper way to call abstract collection's toArray
|
||||
@Suppress("INVISIBLE_MEMBER") collection.toArray() as Array<T>
|
||||
else
|
||||
copyToArrayImpl(collection) as Array<T>
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
internal actual fun <T> copyToArrayImpl(collection: Collection<*>, array: Array<T>): Array<T> {
|
||||
if (array.size < collection.size)
|
||||
return copyToArrayImpl(collection) as Array<T>
|
||||
|
||||
val iterator = collection.iterator()
|
||||
var index = 0
|
||||
while (iterator.hasNext()) {
|
||||
array[index++] = iterator.next() as T
|
||||
}
|
||||
return terminateCollectionToArray(collection.size, array)
|
||||
}
|
||||
copyToArrayImpl(collection) as Array<T>
|
||||
Reference in New Issue
Block a user