implement optimizations

This commit is contained in:
2026-01-15 22:06:28 +01:00
parent ab036f4f9f
commit d40df04e2e
26 changed files with 463 additions and 855 deletions

View File

@@ -7,7 +7,20 @@ interface HashFunction {
val block: Int
fun hash(
value: UByteArray,
): UByteArray
fun hashInto(value: ByteArray, destination: ByteArray)
fun hashInto(value: ByteArray, destination: UByteArray) =
hashInto(value, destination.asByteArray())
fun hashInto(value: UByteArray, destination: UByteArray) =
hashInto(value.asByteArray(), destination.asByteArray())
fun hashInto(value: UByteArray, destination: ByteArray) =
hashInto(value.asByteArray(), destination)
fun hash(value: ByteArray): ByteArray =
ByteArray(bytes).also { hashInto(value, it) }
fun hash(value: UByteArray): UByteArray =
UByteArray(bytes).also { hashInto(value, it) }
}