Skip to content

Apache Lucene open-source search software

Remove the unnecessary grow before append. (#13168)

Zhang Chao9fd047425184
diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/uniformsplit/IntersectBlockReader.java b/lucene/codecs/src/java/org/apache/lucene/codecs/uniformsplit/IntersectBlockReader.java
index 3de978c8f69..ffc37371976 100644
--- a/lucene/codecs/src/java/org/apache/lucene/codecs/uniformsplit/IntersectBlockReader.java
+++ b/lucene/codecs/src/java/org/apache/lucene/codecs/uniformsplit/IntersectBlockReader.java
@@ -566,7 +566,6 @@ public class IntersectBlockReader extends BlockReader {
if (transition.max >= c) {
int nextChar = Math.max(c, transition.min);
// append either the next sequential char, or the minimum transition
- seekBytesRef.grow(seekBytesRef.length() + 1);
seekBytesRef.append((byte) nextChar);
state = transition.dest;
/*
@@ -585,7 +584,6 @@ public class IntersectBlockReader extends BlockReader {
state = transition.dest;
// append the minimum transition
- seekBytesRef.grow(seekBytesRef.length() + 1);
seekBytesRef.append((byte) transition.min);
// we found a loop, record it for faster enumeration
diff --git a/lucene/core/src/java/org/apache/lucene/index/AutomatonTermsEnum.java b/lucene/core/src/java/org/apache/lucene/index/AutomatonTermsEnum.java
index ac16477ce02..ff1d5fa7b52 100644
--- a/lucene/core/src/java/org/apache/lucene/index/AutomatonTermsEnum.java
+++ b/lucene/core/src/java/org/apache/lucene/index/AutomatonTermsEnum.java
@@ -285,7 +285,6 @@ public class AutomatonTermsEnum extends FilteredTermsEnum {
if (transition.max >= c) {
int nextChar = Math.max(c, transition.min);
// append either the next sequential char, or the minimum transition
- seekBytesRef.grow(seekBytesRef.length() + 1);
seekBytesRef.append((byte) nextChar);
state = transition.dest;
/*
@@ -304,7 +303,6 @@ public class AutomatonTermsEnum extends FilteredTermsEnum {
state = transition.dest;
// append the minimum transition
- seekBytesRef.grow(seekBytesRef.length() + 1);
seekBytesRef.append((byte) transition.min);
// we found a loop, record it for faster enumeration