Skip to content

Apache Lucene open-source search software

Remove TODO in FSTCompiler#freezeTail. (#13923)

zhouhui445baee796e0
diff --git a/lucene/core/src/java/org/apache/lucene/util/fst/FSTCompiler.java b/lucene/core/src/java/org/apache/lucene/util/fst/FSTCompiler.java
index 6ed886cb027..43a3bfc6263 100644
--- a/lucene/core/src/java/org/apache/lucene/util/fst/FSTCompiler.java
+++ b/lucene/core/src/java/org/apache/lucene/util/fst/FSTCompiler.java
@@ -820,17 +820,15 @@ public class FSTCompiler<T> {
final UnCompiledNode<T> node = frontier[idx];
final int prevIdx = idx - 1;
final UnCompiledNode<T> parent = frontier[prevIdx];
-
+ // We need use this variable rather than node.output to call replaceLast later, because
+ // compileNode(node) will clear node's state.
final T nextFinalOutput = node.output;
- // We "fake" the node as being final if it has no
- // outgoing arcs; in theory we could leave it
- // as non-final (the FST can represent this), but
- // FSTEnum, Util, etc., have trouble w/ non-final
- // dead-end states:
-
- // TODO: is node.numArcs == 0 always false? we no longer prune any nodes from FST:
- final boolean isFinal = node.isFinal || node.numArcs == 0;
+ // If this node has no outgoing arcs, it should be final.
+ assert node.numArcs != 0 || node.isFinal;
+ // We need use this variable rather than node.isFinal to call replaceLast later, because
+ // compileNode(node) will clear node's state.
+ final boolean isFinal = node.isFinal;
// this node makes it and we now compile it. first,
// compile any targets that were previously