diff options
Diffstat (limited to 'java/src/main/java/com/google/protobuf/LiteralByteString.java')
-rw-r--r-- | java/src/main/java/com/google/protobuf/LiteralByteString.java | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/java/src/main/java/com/google/protobuf/LiteralByteString.java b/java/src/main/java/com/google/protobuf/LiteralByteString.java index 83e71e93..127c574d 100644 --- a/java/src/main/java/com/google/protobuf/LiteralByteString.java +++ b/java/src/main/java/com/google/protobuf/LiteralByteString.java @@ -190,6 +190,15 @@ class LiteralByteString extends ByteString { } if (other instanceof LiteralByteString) { + LiteralByteString otherAsLiteral = (LiteralByteString) other; + // If we know the hash codes and they are not equal, we know the byte + // strings are not equal. + if (hash != 0 + && otherAsLiteral.hash != 0 + && hash != otherAsLiteral.hash) { + return false; + } + return equalsRange((LiteralByteString) other, 0, size()); } else if (other instanceof RopeByteString) { return other.equals(this); |