Skip to content

Apache Lucene open-source search software

Reduce number of calculations in FSTCompiler (#13788)

mrhbj568d1f3fbe7b
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 8fb194b4425..d51c256d48e 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
@@ -817,7 +817,8 @@ public class FSTCompiler<T> {
for (int idx = lastInput.length(); idx >= downTo; idx--) {
final UnCompiledNode<T> node = frontier[idx];
- final UnCompiledNode<T> parent = frontier[idx - 1];
+ final int prevIdx = idx - 1;
+ final UnCompiledNode<T> parent = frontier[prevIdx];
final T nextFinalOutput = node.output;
@@ -833,7 +834,7 @@ public class FSTCompiler<T> {
// this node makes it and we now compile it. first,
// compile any targets that were previously
// undecided:
- parent.replaceLast(lastInput.intAt(idx - 1), compileNode(node), nextFinalOutput, isFinal);
+ parent.replaceLast(lastInput.intAt(prevIdx), compileNode(node), nextFinalOutput, isFinal);
}
}