Null-terminate Collection.toArray destination only in JVM

In other platforms the elements following the collection elements
should not be changed.

As a part of efforts to stabilize Native stdlib.
This commit is contained in:
Abduqodiri Qurbonzoda
2023-06-01 12:52:46 +03:00
committed by Space Team
parent 60455daa9d
commit 6fdfd4e8dd
14 changed files with 46 additions and 40 deletions
@@ -34,8 +34,5 @@ internal actual fun <T> copyToArrayImpl(collection: Collection<*>, array: Array<
while (iterator.hasNext()) {
array[index++] = iterator.next() as T
}
if (index < array.size) {
(array as Array<T?>).fill(null, index)
}
return array
return terminateCollectionToArray(collection.size, array)
}