rmuir commented on code in PR #12194:
URL: https://github.com/apache/lucene/pull/12194#discussion_r1128934912
##########
lucene/core/src/java/org/apache/lucene/util/FixedBitSet.java:
##########
@@ -286,6 +286,33 @@ public int nextSetBit(int index) {
return DocIdSetIterator.NO_MORE_DOCS;
}
+ @Override
+ public int nextClearBit(int index) {
+ assert index >= 0 && index < numBits : "index=" + index + ", numBits=" +
numBits;
+
+ int wordIndex = index >> 6;
+ long word = bits[wordIndex] >> index; // skip all the bits to the right of
index
+
+ if (word == 0) {
+ return index;
+ }
+
+ int n = Long.numberOfTrailingZeros(~word);
+
+ if (n + index % Long.SIZE < Long.SIZE -
Long.numberOfLeadingZeros(bits[wordIndex])) {
+ return index + n;
+ }
+
+ while (++wordIndex < numWords) {
+ word = bits[wordIndex];
+ if (Long.bitCount(word) != Long.SIZE) { // there are 0s in this word
Review Comment:
do you really need to call bitcount instruction and compare to 64, or can
you just do:
```
if (word != -1L) { // there are 0s in this word
```
--
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]