Apache Lucene open-source search software
A small improvement in FuzzyTermsEnum, as the ArrayList was initially allocated with one element less so internal array reallocated every time. This removes the use of ArrayList at all.
Uwe Schindler19a14cbefae9
diff --git a/lucene/src/java/org/apache/lucene/search/FuzzyTermsEnum.java b/lucene/src/java/org/apache/lucene/search/FuzzyTermsEnum.javaindex b2f1fcf6197..83940381347 100644--- a/lucene/src/java/org/apache/lucene/search/FuzzyTermsEnum.java+++ b/lucene/src/java/org/apache/lucene/search/FuzzyTermsEnum.java@@ -33,7 +33,7 @@ import org.apache.lucene.util.automaton.ByteRunAutomaton;import org.apache.lucene.util.automaton.LevenshteinAutomata;import java.io.IOException;-import java.util.ArrayList;+import java.util.Arrays;import java.util.Comparator;import java.util.List;@@ -135,7 +135,7 @@ public final class FuzzyTermsEnum extends TermsEnum {LevenshteinAutomata builder =new LevenshteinAutomata(UnicodeUtil.newString(termText, realPrefixLength, termText.length - realPrefixLength));- runAutomata = new ArrayList<ByteRunAutomaton>(maxDistance);+ final ByteRunAutomaton[] ra = new ByteRunAutomaton[maxDistance + 1];for (int i = 0; i <= maxDistance; i++) {Automaton a = builder.toAutomaton(i);// constant prefix@@ -144,8 +144,9 @@ public final class FuzzyTermsEnum extends TermsEnum {UnicodeUtil.newString(termText, 0, realPrefixLength));a = BasicOperations.concatenate(prefix, a);}- runAutomata.add(new ByteRunAutomaton(a));+ ra[i] = new ByteRunAutomaton(a);}+ runAutomata = Arrays.asList(ra);}}