Move copyToArrayImpl implementation to Common source set
This commit is contained in:
committed by
Space Team
parent
6fdfd4e8dd
commit
7010bf2c20
@@ -18,17 +18,4 @@ public actual inline fun <reified T> Collection<T>.toTypedArray(): Array<T> {
|
||||
for (element in this) result[index++] = element
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return result 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)
|
||||
}
|
||||
Reference in New Issue
Block a user