Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

AVRO-4049: Use JDK Arrays equal to test if two UTF8 strings are equal #3131

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lang/java/avro/src/main/java/org/apache/avro/util/Utf8.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ public boolean equals(Object o) {
Utf8 that = (Utf8) o;
if (!(this.length == that.length))
return false;
// For longer strings, leverage vectorization (JDK 9+) to determine equality
// For shorter strings, the overhead of this method defeats the value
if (this.length > 7)
return Arrays.equals(this.bytes, 0, this.length, that.bytes, 0, that.length);
byte[] thatBytes = that.bytes;
for (int i = 0; i < this.length; i++)
if (bytes[i] != thatBytes[i])
Expand Down
Loading