From 9926d89555927e9a995f744ad8747e2967b7358a Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Tue, 14 Oct 2025 07:30:44 -0700 Subject: [PATCH] Optimize LiteralByteString equals(LiteralByteString) to go straight to Arrays.equals() on the bytes, rather than falling back to a loop. PiperOrigin-RevId: 819211918 --- java/core/src/main/java/com/google/protobuf/ByteString.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/java/core/src/main/java/com/google/protobuf/ByteString.java b/java/core/src/main/java/com/google/protobuf/ByteString.java index 8d1d0c8d6ee79..4e94fda672e44 100644 --- a/java/core/src/main/java/com/google/protobuf/ByteString.java +++ b/java/core/src/main/java/com/google/protobuf/ByteString.java @@ -1555,8 +1555,7 @@ public final boolean equals( if (thisHash != 0 && thatHash != 0 && thisHash != thatHash) { return false; } - - return equalsRange((LiteralByteString) other, 0, size()); + return Arrays.equals(bytes, otherAsLiteral.bytes); } else { // RopeByteString and NioByteString. return other.equals(this);