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


##########
lucene/core/src/java/org/apache/lucene/util/BitUtil.java:
##########
@@ -303,4 +303,12 @@ public static int zigZagDecode(int i) {
   public static long zigZagDecode(long l) {
     return ((l >>> 1) ^ -(l & 1));
   }
+
+  /**
+   * Return true if, and only if, the provided integer - treated as an 
unsigned integer - is either
+   * 0 or a power of two.
+   */
+  public static boolean isZeroOrPowerOfTwo(int x) {
+    return (x & (x - 1)) == 0;
+  }

Review Comment:
   Is there a reason for the fancy power-of-two "slow-start" function? 
   
   Or would it be enough to just do something such as `x & 0xFFFF = 0`  to 
amortize it for every N calls (65k is just a made up number here)



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