dweiss commented on code in PR #13936: URL: https://github.com/apache/lucene/pull/13936#discussion_r1808146179
########## lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java: ########## @@ -270,7 +280,7 @@ public final boolean remove(T element) { return false; } - private final boolean upHeap(int origPos) { + private boolean upHeap(int origPos, T[] heap) { Review Comment: > the compiler can't hoist the field access out of the loop I think (maybe in some happy cases escape analysis helps here). I don't think there's anything in the spec preventing it from doing so. The final keyword is indeed for the java compiler, not for the jvm, but... you know - it's easy to show that c2 can happily hoist out field reads, try it. ``` public final class SuperSoft { private static boolean ready; public static void startThread() { new Thread() { public void run() { try { sleep(2000); } catch (Exception e) { /* ignore */ } System.out.println("Marking loop exit."); ready = true; } }.start(); } public static void main(String[] args) { startThread(); System.out.println("Entering the loop..."); while (!ready) { // Do nothing. } System.out.println("Done, I left the loop!"); } } ``` This aside, I am not rejecting the change - I just suggested to rename one local variable (s) and to remove method parameter in favor of a single local variable read - this should result in identical code to what your 1% gain was producing, if my gut feeling is right. -- 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