8178352: BitMap::get_next_zero_offset may give wrong result on Mac
Invert and search initial word for trailing ones. Reviewed-by: stefank, cjplummer
This commit is contained in:
parent
c386cec7b1
commit
a896bf909c
@ -222,12 +222,12 @@ BitMap::get_next_zero_offset(idx_t l_offset, idx_t r_offset) const {
|
|||||||
idx_t res_offset = l_offset;
|
idx_t res_offset = l_offset;
|
||||||
|
|
||||||
// check bits including and to the _left_ of offset's position
|
// check bits including and to the _left_ of offset's position
|
||||||
idx_t pos = res_offset & (BitsPerWord - 1);
|
idx_t pos = bit_in_word(res_offset);
|
||||||
bm_word_t res = (map(index) >> pos) | left_n_bits((int)pos);
|
bm_word_t res = ~map(index) >> pos; // flip bits and shift for l_offset
|
||||||
|
|
||||||
if (res != ~(bm_word_t)0) {
|
if (res != 0) {
|
||||||
// find the position of the 0-bit
|
// find the position of the 1-bit
|
||||||
for (; res & 1; res_offset++) {
|
for (; !(res & 1); res_offset++) {
|
||||||
res = res >> 1;
|
res = res >> 1;
|
||||||
}
|
}
|
||||||
assert(res_offset >= l_offset, "just checking");
|
assert(res_offset >= l_offset, "just checking");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user