remove code duplication by making getSortedTransitions public

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1036544 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2010-11-18 17:28:27 +00:00
parent a5d73e7dec
commit 30c2ff16b6
2 changed files with 2 additions and 8 deletions

View File

@ -26,7 +26,6 @@ import org.apache.lucene.util.IntsRef;
import org.apache.lucene.util.automaton.Automaton; import org.apache.lucene.util.automaton.Automaton;
import org.apache.lucene.util.automaton.ByteRunAutomaton; import org.apache.lucene.util.automaton.ByteRunAutomaton;
import org.apache.lucene.util.automaton.SpecialOperations; import org.apache.lucene.util.automaton.SpecialOperations;
import org.apache.lucene.util.automaton.State;
import org.apache.lucene.util.automaton.Transition; import org.apache.lucene.util.automaton.Transition;
/** /**
@ -102,12 +101,7 @@ public class AutomatonTermsEnum extends FilteredTermsEnum {
} }
// build a cache of sorted transitions for every state // build a cache of sorted transitions for every state
allTransitions = new Transition[runAutomaton.getSize()][]; allTransitions = this.automaton.getSortedTransitions();
for (State state : this.automaton.getNumberedStates()) {
state.sortTransitions(Transition.CompareByMinMaxThenDest);
state.trimTransitionsArray();
allTransitions[state.getNumber()] = state.transitionsArray;
}
// used for path tracking, where each bit is a numbered state. // used for path tracking, where each bit is a numbered state.
visited = new long[runAutomaton.getSize()]; visited = new long[runAutomaton.getSize()];

View File

@ -487,7 +487,7 @@ public class Automaton implements Serializable, Cloneable {
* Returns a sorted array of transitions for each state (and sets state * Returns a sorted array of transitions for each state (and sets state
* numbers). * numbers).
*/ */
Transition[][] getSortedTransitions() { public Transition[][] getSortedTransitions() {
final State[] states = getNumberedStates(); final State[] states = getNumberedStates();
Transition[][] transitions = new Transition[states.length][]; Transition[][] transitions = new Transition[states.length][];
for (State s : states) { for (State s : states) {