switch to signed-first approach
All checks were successful
/ test (pull_request) Successful in 2m47s
All checks were successful
/ test (pull_request) Successful in 2m47s
It turns out signed math is more performant
This commit is contained in:
@@ -3,14 +3,8 @@ package com.infendro.bytes.uint
|
||||
import com.infendro.bytes.ByteOrder
|
||||
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
|
||||
|
||||
fun UInt.toUByteArray(order: ByteOrder = BIG_ENDIAN) =
|
||||
UByteArray(4).also { copyInto(it, order = order) }
|
||||
|
||||
fun UInt.toByteArray(order: ByteOrder = BIG_ENDIAN) =
|
||||
ByteArray(4).also { copyInto(it, order = order) }
|
||||
|
||||
fun UIntArray.toUByteArray(order: ByteOrder = BIG_ENDIAN) =
|
||||
UByteArray(size * 4).also { copyInto(it, order = order) }
|
||||
|
||||
fun UIntArray.toByteArray(order: ByteOrder = BIG_ENDIAN) =
|
||||
ByteArray(size * 4).also { copyInto(it, order = order) }
|
||||
fun UInt.toUByteArray(order: ByteOrder = BIG_ENDIAN) =
|
||||
UByteArray(4).also { copyInto(it, order = order) }
|
||||
|
||||
Reference in New Issue
Block a user