optimized BitArray.equals
This commit is contained in:
parent
3481a718b1
commit
e8b630715a
@ -183,7 +183,7 @@ class Script(
|
|||||||
catch( e: ExecutionError ) {
|
catch( e: ExecutionError ) {
|
||||||
e.errorObject
|
e.errorObject
|
||||||
}
|
}
|
||||||
catch (e: ScriptError) {
|
catch (_: ScriptError) {
|
||||||
ObjNull
|
ObjNull
|
||||||
}
|
}
|
||||||
result ?: raiseError(ObjAssertionFailedException(this,"Expected exception but nothing was thrown"))
|
result ?: raiseError(ObjAssertionFailedException(this,"Expected exception but nothing was thrown"))
|
||||||
|
@ -81,7 +81,13 @@ class BitArray(val bytes: UByteArray, val lastByteBits: Int) : BitList {
|
|||||||
fun asUByteArray(): UByteArray = bytes
|
fun asUByteArray(): UByteArray = bytes
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
return other is BitList && this.compareTo(other) == 0
|
return when(other) {
|
||||||
|
is BitArray ->
|
||||||
|
// important: size must match as trailing zero bits will generate false eq otherwise:
|
||||||
|
size == other.size && bytes contentEquals other.bytes
|
||||||
|
is BitList -> compareTo(other) == 0
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
override fun hashCode(): Int {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user