refactor
This commit is contained in:
@@ -9,17 +9,7 @@ fun UInt.toByteArray(
|
||||
val offset = (3 - i) * 8
|
||||
(this shr offset).toByte()
|
||||
}
|
||||
return order.normalize(bytes)
|
||||
}
|
||||
|
||||
fun UIntArray.toByteArray(
|
||||
order: ByteOrder = BIG_ENDIAN,
|
||||
): ByteArray {
|
||||
val bytes = mutableListOf<Byte>()
|
||||
for (n in this) {
|
||||
bytes += n.toByteArray(order).toList()
|
||||
}
|
||||
return bytes.toByteArray()
|
||||
return bytes.normalize(order)
|
||||
}
|
||||
|
||||
fun UInt.toUByteArray(
|
||||
@@ -29,15 +19,5 @@ fun UInt.toUByteArray(
|
||||
val offset = (3 - i) * 8
|
||||
(this shr offset).toUByte()
|
||||
}
|
||||
return order.normalize(bytes)
|
||||
}
|
||||
|
||||
fun UIntArray.toUByteArray(
|
||||
order: ByteOrder = BIG_ENDIAN,
|
||||
): UByteArray {
|
||||
val bytes = mutableListOf<UByte>()
|
||||
for (n in this) {
|
||||
bytes += n.toUByteArray(order)
|
||||
}
|
||||
return bytes.toUByteArray()
|
||||
return bytes.normalize(order)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user