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.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@965216 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2010-07-18 12:08:21 +00:00
parent 42aa9a20b3
commit 19a14cbefa
1 changed files with 4 additions and 3 deletions

View File

@ -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);
}
}