rmuir commented on code in PR #14906:
URL: https://github.com/apache/lucene/pull/14906#discussion_r2188800620


##########
lucene/core/src/java/org/apache/lucene/search/ScorerUtil.java:
##########
@@ -157,11 +157,10 @@ static void filterCompetitiveHits(
 
     int newSize = 0;
     for (int i = 0; i < buffer.size; ++i) {
-      if (buffer.scores[i] >= minRequiredScore) {
-        buffer.docs[newSize] = buffer.docs[i];
-        buffer.scores[newSize] = buffer.scores[i];
-        newSize++;
-      }
+      int inc = buffer.scores[i] >= minRequiredScore ? 1 : 0;
+      buffer.docs[newSize] = buffer.docs[i];
+      buffer.scores[newSize] = buffer.scores[i];
+      newSize += inc;

Review Comment:
   nit: to me it is more clear what happens if the `inc` is moved down to right 
before where it is used?
   
   ```suggestion
         buffer.docs[newSize] = buffer.docs[i];
         buffer.scores[newSize] = buffer.scores[i];
         int inc = buffer.scores[newSize] >= minRequiredScore ? 1 : 0;
         newSize += inc;
   ```
   
   edit: i tried to also make it check `buffer.scores[newSize]` instead as I 
have less context. but high-level, just trying to make the logic less sneaky.



-- 
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

Reply via email to