mikemccand commented on code in PR #12692: URL: https://github.com/apache/lucene/pull/12692#discussion_r1365740888
########## lucene/core/src/java/org/apache/lucene/util/fst/FST.java: ########## @@ -1081,22 +1085,30 @@ public Arc<T> findTargetArc(int labelToMatch, Arc<T> follow, Arc<T> arc, BytesRe } // Linear scan - readFirstRealTargetArc(follow.target(), arc, in); - + readFirstArcInfo(follow.target(), arc, in); + in.setPosition(arc.nextArc()); while (true) { - // System.out.println(" non-bs cycle"); - // TODO: we should fix this code to not have to create - // object for the output of every arc we scan... only - // for the matching arc, if found - if (arc.label() == labelToMatch) { - // System.out.println(" found!"); - return arc; - } else if (arc.label() > labelToMatch) { + assert arc.bytesPerArc() == 0; + flags = arc.flags = in.readByte(); + long pos = in.getPosition(); + int label = readLabel(in); + if (label == labelToMatch) { + in.setPosition(pos); + return readArc(arc, in); + } else if (label > labelToMatch) { return null; } else if (arc.isLast()) { return null; } else { - readNextRealArc(arc, in); + if (flag(flags, BIT_ARC_HAS_OUTPUT)) { + outputs.skipOutput(in); + } + if (flag(flags, BIT_ARC_HAS_FINAL_OUTPUT)) { Review Comment: OK indeed, looking at the code again, an arc can have both a "transition" output (concatenated when you follow this arc), and a "final" output (concatenated if your input ends on the node that this arc leads to). So we cannot use an `else` indeed -- we must allow for both. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org