jpountz commented on code in PR #14176:
URL: https://github.com/apache/lucene/pull/14176#discussion_r1940875523


##########
lucene/core/src/java/org/apache/lucene/util/bkd/DocIdsWriter.java:
##########
@@ -115,30 +117,24 @@ void writeDocIds(int[] docIds, int start, int count, 
DataOutput out) throws IOEx
       if (max <= 0xFFFFFF) {
         out.writeByte(BPV_24);
         // write them the same way we are reading them.
-        int i;
-        for (i = 0; i < count - 7; i += 8) {
-          int doc1 = docIds[start + i];
-          int doc2 = docIds[start + i + 1];
-          int doc3 = docIds[start + i + 2];
-          int doc4 = docIds[start + i + 3];
-          int doc5 = docIds[start + i + 4];
-          int doc6 = docIds[start + i + 5];
-          int doc7 = docIds[start + i + 6];
-          int doc8 = docIds[start + i + 7];
-          long l1 = (doc1 & 0xffffffL) << 40 | (doc2 & 0xffffffL) << 16 | 
((doc3 >>> 8) & 0xffffL);
-          long l2 =
-              (doc3 & 0xffL) << 56
-                  | (doc4 & 0xffffffL) << 32
-                  | (doc5 & 0xffffffL) << 8
-                  | ((doc6 >> 16) & 0xffL);
-          long l3 = (doc6 & 0xffffL) << 48 | (doc7 & 0xffffffL) << 24 | (doc8 
& 0xffffffL);
-          out.writeLong(l1);
-          out.writeLong(l2);
-          out.writeLong(l3);
+        final int quarterLen = count >>> 2;

Review Comment:
   In other places in the code base, we prefer to use a signed shift, which is 
less likely to hide a bug if `count` ended up being negative for some reason 
(e.g. overflow)
   ```suggestion
           final int quarterLen = count >> 2;
   ```



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