This commit is contained in:
@@ -19,16 +19,18 @@ fun UByteArray.copyInto(
|
||||
when (order) {
|
||||
BIG_ENDIAN -> {
|
||||
repeat(length / 4) { i ->
|
||||
val offset = startIndex + (i * 4)
|
||||
destination[destinationOffset + i] =
|
||||
(this[startIndex].toUInt() shl 24) or (this[startIndex + 1].toUInt() shl 16) or
|
||||
(this[startIndex + 2].toUInt() shl 8) or this[startIndex + 3].toUInt()
|
||||
(this[offset].toUInt() shl 24) or (this[offset + 1].toUInt() shl 16) or
|
||||
(this[offset + 2].toUInt() shl 8) or this[offset + 3].toUInt()
|
||||
}
|
||||
}
|
||||
LITTLE_ENDIAN -> {
|
||||
repeat(length / 4) { i ->
|
||||
val offset = startIndex + (i * 4)
|
||||
destination[destinationOffset + i] =
|
||||
this[startIndex].toUInt() or (this[startIndex + 1].toUInt() shl 8) or
|
||||
(this[startIndex + 2].toUInt() shl 16) or (this[startIndex + 3].toUInt() shl 24)
|
||||
this[offset].toUInt() or (this[offset + 1].toUInt() shl 8) or
|
||||
(this[offset + 2].toUInt() shl 16) or (this[offset + 3].toUInt() shl 24)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,21 +58,23 @@ fun UByteArray.copyInto(
|
||||
|
||||
when (order) {
|
||||
BIG_ENDIAN -> {
|
||||
repeat(length / 4) { i ->
|
||||
repeat(length / 8) { i ->
|
||||
val offset = startIndex + (i * 8)
|
||||
destination[destinationOffset + i] =
|
||||
(this[startIndex].toULong() shl 56) or (this[startIndex + 1].toULong() shl 48) or
|
||||
(this[startIndex + 2].toULong() shl 40) or (this[startIndex + 3].toULong() shl 32) or
|
||||
(this[startIndex + 4].toULong() shl 24) or (this[startIndex + 5].toULong() shl 16) or
|
||||
(this[startIndex + 6].toULong() shl 8) or this[startIndex + 7].toULong()
|
||||
(this[offset].toULong() shl 56) or (this[offset + 1].toULong() shl 48) or
|
||||
(this[offset + 2].toULong() shl 40) or (this[offset + 3].toULong() shl 32) or
|
||||
(this[offset + 4].toULong() shl 24) or (this[offset + 5].toULong() shl 16) or
|
||||
(this[offset + 6].toULong() shl 8) or this[offset + 7].toULong()
|
||||
}
|
||||
}
|
||||
LITTLE_ENDIAN -> {
|
||||
repeat(length / 4) { i ->
|
||||
repeat(length / 8) { i ->
|
||||
val offset = startIndex + (i * 8)
|
||||
destination[destinationOffset + i] =
|
||||
this[startIndex].toULong() or (this[startIndex + 1].toULong() shl 8) or
|
||||
(this[startIndex + 2].toULong() shl 16) or (this[startIndex + 3].toULong() shl 24) or
|
||||
(this[startIndex + 4].toULong() shl 32) or (this[startIndex + 5].toULong() shl 40) or
|
||||
(this[startIndex + 6].toULong() shl 48) or (this[startIndex + 7].toULong() shl 56)
|
||||
this[offset].toULong() or (this[offset + 1].toULong() shl 8) or
|
||||
(this[offset + 2].toULong() shl 16) or (this[offset + 3].toULong() shl 24) or
|
||||
(this[offset + 4].toULong() shl 32) or (this[offset + 5].toULong() shl 40) or
|
||||
(this[offset + 6].toULong() shl 48) or (this[offset + 7].toULong() shl 56)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,8 +45,27 @@ fun UIntArray.copyInto(
|
||||
require(startIndex in 0..(size - length))
|
||||
require(destinationOffset in 0..(destination.size - (length * 4)))
|
||||
|
||||
repeat(length) { i ->
|
||||
this[startIndex + i].copyInto(destination, destinationOffset + (i * 4), order)
|
||||
when (order) {
|
||||
BIG_ENDIAN -> {
|
||||
repeat(length) { i ->
|
||||
val offset = destinationOffset + (i * 4)
|
||||
val value = this[startIndex + i]
|
||||
destination[offset] = (value shr 24).toUByte()
|
||||
destination[offset + 1] = (value shr 16).toUByte()
|
||||
destination[offset + 2] = (value shr 8).toUByte()
|
||||
destination[offset + 3] = value.toUByte()
|
||||
}
|
||||
}
|
||||
LITTLE_ENDIAN -> {
|
||||
repeat(length) { i ->
|
||||
val offset = destinationOffset + (i * 4)
|
||||
val value = this[startIndex + i]
|
||||
destination[offset] = value.toUByte()
|
||||
destination[offset + 1] = (value shr 8).toUByte()
|
||||
destination[offset + 2] = (value shr 16).toUByte()
|
||||
destination[offset + 3] = (value shr 24).toUByte()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,8 +53,35 @@ fun ULongArray.copyInto(
|
||||
require(startIndex in 0..(size - length))
|
||||
require(destinationOffset in 0..(destination.size - (length * 8)))
|
||||
|
||||
repeat(length) { i ->
|
||||
this[startIndex + i].copyInto(destination, destinationOffset + (i * 8), order)
|
||||
when (order) {
|
||||
BIG_ENDIAN -> {
|
||||
repeat(length) { i ->
|
||||
val offset = destinationOffset + (i * 8)
|
||||
val value = this[startIndex + i]
|
||||
destination[offset] = (value shr 56).toUByte()
|
||||
destination[offset + 1] = (value shr 48).toUByte()
|
||||
destination[offset + 2] = (value shr 40).toUByte()
|
||||
destination[offset + 3] = (value shr 32).toUByte()
|
||||
destination[offset + 4] = (value shr 24).toUByte()
|
||||
destination[offset + 5] = (value shr 16).toUByte()
|
||||
destination[offset + 6] = (value shr 8).toUByte()
|
||||
destination[offset + 7] = value.toUByte()
|
||||
}
|
||||
}
|
||||
LITTLE_ENDIAN -> {
|
||||
repeat(length) { i ->
|
||||
val offset = destinationOffset + (i * 8)
|
||||
val value = this[startIndex + i]
|
||||
destination[offset] = value.toUByte()
|
||||
destination[offset + 1] = (value shr 8).toUByte()
|
||||
destination[offset + 2] = (value shr 16).toUByte()
|
||||
destination[offset + 3] = (value shr 24).toUByte()
|
||||
destination[offset + 4] = (value shr 32).toUByte()
|
||||
destination[offset + 5] = (value shr 40).toUByte()
|
||||
destination[offset + 6] = (value shr 48).toUByte()
|
||||
destination[offset + 7] = (value shr 56).toUByte()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user