Skip to content

Commit

Permalink
AVRO-2801: Cache Hashcode of UTF8 Strings in all Set Methods (#856)
Browse files Browse the repository at this point in the history
Co-authored-by: David Mollitor <dmollitor@apache.org>
  • Loading branch information
belugabehr and belugabehr committed Apr 22, 2020
1 parent 97c2aeb commit 8e345c4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lang/java/avro/src/main/java/org/apache/avro/util/Utf8.java
Expand Up @@ -128,6 +128,7 @@ public Utf8 set(String string) {
this.bytes = getBytesFor(string);
this.length = bytes.length;
this.string = string;
this.hasHash = false;
return this;
}

Expand All @@ -138,6 +139,8 @@ public Utf8 set(Utf8 other) {
this.length = other.length;
System.arraycopy(other.bytes, 0, bytes, 0, length);
this.string = other.string;
this.hash = other.hash;
this.hasHash = other.hasHash;
return this;
}

Expand Down

0 comments on commit 8e345c4

Please sign in to comment.