zhaih commented on code in PR #949:
URL: https://github.com/apache/lucene/pull/949#discussion_r893146609


##########
lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java:
##########
@@ -191,15 +191,17 @@ public static int oversize(int minTargetSize, int 
bytesPerElement) {
           return newSize;
       }
     } else {
-      // round up to 4 byte alignment in 64bit env
+      // round up to 4 byte alignment in 32bit env

Review Comment:
   this should still be 8 byte alignment, but with 4 bytes offset given by 
array header, probably it's better to mention in 32 bit machine the array 
header is 12 bytes so the calculation below become reasonable.



##########
lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java:
##########
@@ -191,15 +191,17 @@ public static int oversize(int minTargetSize, int 
bytesPerElement) {
           return newSize;
       }
     } else {
-      // round up to 4 byte alignment in 64bit env
+      // round up to 4 byte alignment in 32bit env
       switch (bytesPerElement) {
-        case 2:
-          // round up to multiple of 2
-          return (newSize + 1) & 0x7ffffffe;
         case 1:
-          // round up to multiple of 4
-          return (newSize + 3) & 0x7ffffffc;
+          // round up to multiple of 8 plus 4

Review Comment:
   This is not round "up" strictly speaking since you only round up 5-7 but not 
1-4, I'm not sure what's the right words but maybe just say "align with size of 
4,12,20..."?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to