Make a more correct implementation of unsigned arrays copyInto

Return the destination array instead of the destination storage array
wrapped in a new unsigned array. The difference should be
indistinguishable, however in JS, where inline classes are not inlined yet,
it had resulted in an extra wrapper.
This commit is contained in:
Ilya Gorbunov
2018-09-26 05:01:57 +03:00
parent 1a20b1f357
commit 0c81e30d46
2 changed files with 12 additions and 5 deletions
@@ -346,7 +346,8 @@ public fun UShortArray.contentToString(): String {
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.copyInto(destination: UIntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): UIntArray {
return UIntArray(storage.copyInto(destination.storage, destinationOffset, startIndex, endIndex))
storage.copyInto(destination.storage, destinationOffset, startIndex, endIndex)
return destination
}
/**
@@ -369,7 +370,8 @@ public inline fun UIntArray.copyInto(destination: UIntArray, destinationOffset:
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.copyInto(destination: ULongArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): ULongArray {
return ULongArray(storage.copyInto(destination.storage, destinationOffset, startIndex, endIndex))
storage.copyInto(destination.storage, destinationOffset, startIndex, endIndex)
return destination
}
/**
@@ -392,7 +394,8 @@ public inline fun ULongArray.copyInto(destination: ULongArray, destinationOffset
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.copyInto(destination: UByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): UByteArray {
return UByteArray(storage.copyInto(destination.storage, destinationOffset, startIndex, endIndex))
storage.copyInto(destination.storage, destinationOffset, startIndex, endIndex)
return destination
}
/**
@@ -415,7 +418,8 @@ public inline fun UByteArray.copyInto(destination: UByteArray, destinationOffset
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.copyInto(destination: UShortArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): UShortArray {
return UShortArray(storage.copyInto(destination.storage, destinationOffset, startIndex, endIndex))
storage.copyInto(destination.storage, destinationOffset, startIndex, endIndex)
return destination
}
/**