Skip to content

Apache Lucene open-source search software

in BytesRefHash constructor avoid duplicate BytesStartArray.bytesUsed() call (#13032)

Christine Poerschkebff5ac0ed01d
diff --git a/lucene/core/src/java/org/apache/lucene/util/BytesRefHash.java b/lucene/core/src/java/org/apache/lucene/util/BytesRefHash.java
index f65a4e38deb..9e1276abdf1 100644
--- a/lucene/core/src/java/org/apache/lucene/util/BytesRefHash.java
+++ b/lucene/core/src/java/org/apache/lucene/util/BytesRefHash.java
@@ -79,8 +79,8 @@ public final class BytesRefHash implements Accountable {
Arrays.fill(ids, -1);
this.bytesStartArray = bytesStartArray;
bytesStart = bytesStartArray.init();
- bytesUsed =
- bytesStartArray.bytesUsed() == null ? Counter.newCounter() : bytesStartArray.bytesUsed();
+ final Counter bytesUsed = bytesStartArray.bytesUsed();
+ this.bytesUsed = bytesUsed == null ? Counter.newCounter() : bytesUsed;
bytesUsed.addAndGet(hashSize * (long) Integer.BYTES);
}