original-brownbear commented on code in PR #13937: URL: https://github.com/apache/lucene/pull/13937#discussion_r1807578084
########## lucene/queries/src/java/org/apache/lucene/queries/intervals/OrderedIntervalsSource.java: ########## @@ -127,29 +127,31 @@ public int nextInterval() throws IOException { final var subIterators = this.subIterators; int currentIndex = i; while (true) { + int prevEnd = subIterators.get(currentIndex - 1).end(); while (true) { - var prev = subIterators.get(currentIndex - 1); - if (prev.end() >= lastStart) { + if (prevEnd >= lastStart) { i = currentIndex; return start; } if (currentIndex == subIterators.size()) { break; } final IntervalIterator current = subIterators.get(currentIndex); - if (minimizing && (current.start() > prev.end())) { + if (minimizing && (current.start() > prevEnd)) { break; } + int currentStart; do { if (current.end() >= lastStart - || current.nextInterval() == IntervalIterator.NO_MORE_INTERVALS) { + || (currentStart = current.nextInterval()) == IntervalIterator.NO_MORE_INTERVALS) { i = currentIndex; return start; } - } while (current.start() <= prev.end()); + } while (currentStart <= prevEnd); currentIndex++; + prevEnd = current.end(); } - var first = subIterators.getFirst(); + var first = subIterators.get(0); Review Comment: I tried some more tricks here around just getting `first` once at the beginning of the loop (and similar optimisations that tried to exploit loop invariants) but to no avail (in fact those resulted in slow-downs). Seems the compiler eventually does not like having too many local variables around. -- 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