gsmiller commented on code in PR #995:
URL: https://github.com/apache/lucene/pull/995#discussion_r910345129


##########
lucene/core/src/java/org/apache/lucene/search/SortedSetSelector.java:
##########
@@ -304,25 +306,19 @@ public int lookupTerm(BytesRef key) throws IOException {
 
     private void setOrd() throws IOException {
       if (docID() != NO_MORE_DOCS) {
-        int upto = 0;
-        while (true) {
-          long nextOrd = in.nextOrd();
-          if (nextOrd == NO_MORE_ORDS) {
-            break;
-          }
-          if (upto == ords.length) {
-            ords = ArrayUtil.grow(ords);
-          }
-          ords[upto++] = (int) nextOrd;
-        }
-
-        if (upto == 0) {
+        int docValueCount = in.docValueCount();
+        if (docValueCount == 0) {
           // iterator should not have returned this docID if it has no ords:
           assert false;
           ord = (int) NO_MORE_ORDS;
-        } else {
-          ord = ords[(upto - 1) >>> 1];
+          return;
+        }
+
+        ords = ArrayUtil.grow(ords, docValueCount);
+        for (int i = 0; i < docValueCount; i++) {
+          ords[i] = (int) in.nextOrd();
         }
+        ord = ords[(docValueCount - 1) >>> 1];

Review Comment:
   Good point. Tweaked this (and the other location).



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