Make compareTo of bytestring faster
This commit is contained in:
parent
de735cc5b8
commit
32b8c4e6d5
@ -87,6 +87,14 @@ class ArrayByteString extends ByteString {
|
||||
return hc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ByteString that) {
|
||||
if (that instanceof ArrayByteString bstring)
|
||||
return Arrays.compare(bytes, bstring.bytes);
|
||||
|
||||
return super.compareTo(that);
|
||||
}
|
||||
|
||||
@Override
|
||||
int maybeHashCode() {
|
||||
return hashCode;
|
||||
|
@ -96,6 +96,14 @@ class StringByteString extends ByteString {
|
||||
return thisIterator.hasNext() == thatIterator.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ByteString that) {
|
||||
if (that instanceof StringByteString bstring)
|
||||
return string.compareTo(bstring.string);
|
||||
|
||||
return super.compareTo(that);
|
||||
}
|
||||
|
||||
private int computeHashCode() {
|
||||
int hc = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user