Skip to content

Commit c91b9be

Browse files
committed
fixed compilation bitarray.h
1 parent fae9dcb commit c91b9be

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/core/bitarray.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
#include <memory>
66
#include <cassert>
77

8+
inline uint8_t bitwise_count_bits(uint8_t v) {
9+
v = (v & 0x55) + ((v >> 1) & 0x55);
10+
v = (v & 0x33) + ((v >> 2) & 0x33);
11+
return (v & 0x0f) + ((v >> 4) & 0x0f);
12+
}
13+
814
template <typename parent_type>
915
struct bitarray_base {
1016
typedef parent_type self_type;
@@ -326,7 +332,7 @@ struct sbitarray : public bitarray_base<sbitarray<bits>> {
326332
result += bw_count_bits(_data[i]);
327333
}
328334
const uint32_t cur = _data[idx] & ((1 << (id % 32)) - 1);
329-
result += bw_count_bits(cur);
335+
result += bitwise_count_bits(cur);
330336

331337
return (result);
332338
}

0 commit comments

Comments
 (0)