From 9cd6a24be43e0b89d48c6d885f1a7833ea50fc16 Mon Sep 17 00:00:00 2001 From: mrhbj <1825636423@qq.com> Date: Sat, 14 Sep 2024 22:51:12 +0800 Subject: [PATCH] Reduce number of calculations in FSTCompiler (#13788) * Simplify FST return * Reduce number of calculations in FSTCompiler --- .../src/java/org/apache/lucene/util/fst/FSTCompiler.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 6bbe75d1065f..05d37d93b9ae 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 @@ private void freezeTail(int prefixLenPlus1) throws IOException { for (int idx = lastInput.length(); idx >= downTo; idx--) { final UnCompiledNode node = frontier[idx]; - final UnCompiledNode parent = frontier[idx - 1]; + final int prevIdx = idx - 1; + final UnCompiledNode parent = frontier[prevIdx]; final T nextFinalOutput = node.output; @@ -833,7 +834,7 @@ private void freezeTail(int prefixLenPlus1) throws IOException { // 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); } }