implement optimizations

This commit is contained in:
2026-01-14 15:36:50 +01:00
parent 9391009403
commit cc9961084c
31 changed files with 1025 additions and 1037 deletions

View File

@@ -0,0 +1,70 @@
package com.infendro.bytes.bytearray
import com.infendro.bytes.ubytearray.*
fun ByteArray.invInto(
destination: ByteArray,
destinationOffset: Int = 0,
startIndex: Int = 0,
endIndex: Int = size,
) = asUByteArray().invInto(destination.asUByteArray(), destinationOffset, startIndex, endIndex)
fun ByteArray.inv() =
(asUByteArray().inv()).asByteArray()
fun ByteArray.andInto(
that: ByteArray,
destination: ByteArray,
destinationOffset: Int = 0,
startIndex: Int = 0,
endIndex: Int = size,
thatStartIndex: Int = 0,
) = asUByteArray().andInto(
that.asUByteArray(),
destination.asUByteArray(),
destinationOffset,
startIndex,
endIndex,
thatStartIndex,
)
infix fun ByteArray.and(that: ByteArray) =
(this.asUByteArray() and that.asUByteArray()).asByteArray()
fun ByteArray.orInto(
that: ByteArray,
destination: ByteArray,
destinationOffset: Int = 0,
startIndex: Int = 0,
endIndex: Int = size,
thatStartIndex: Int = 0,
) = asUByteArray().orInto(
that.asUByteArray(),
destination.asUByteArray(),
destinationOffset,
startIndex,
endIndex,
thatStartIndex,
)
infix fun ByteArray.or(that: ByteArray) =
(this.asUByteArray() or that.asUByteArray()).asByteArray()
fun ByteArray.xorInto(
that: ByteArray,
destination: ByteArray,
destinationOffset: Int = 0,
startIndex: Int = 0,
endIndex: Int = size,
thatStartIndex: Int = 0,
) = asUByteArray().xorInto(
that.asUByteArray(),
destination.asUByteArray(),
destinationOffset,
startIndex,
endIndex,
thatStartIndex,
)
infix fun ByteArray.xor(that: ByteArray) =
(this.asUByteArray() xor that.asUByteArray()).asByteArray()