Fix BitMap calculating incorrect true bit count

This commit is contained in:
Andrii Doroshenko (Xrayez) 2019-04-04 19:11:39 +03:00
parent a18989602b
commit b16946dea6
1 changed files with 2 additions and 1 deletions

View File

@ -96,7 +96,7 @@ int BitMap::get_true_bit_count() const {
const uint8_t *d = bitmask.ptr(); const uint8_t *d = bitmask.ptr();
int c = 0; int c = 0;
//fast, almot branchless version //fast, almost branchless version
for (int i = 0; i < ds; i++) { for (int i = 0; i < ds; i++) {
@ -106,6 +106,7 @@ int BitMap::get_true_bit_count() const {
c += (d[i] & (1 << 4)) >> 4; c += (d[i] & (1 << 4)) >> 4;
c += (d[i] & (1 << 3)) >> 3; c += (d[i] & (1 << 3)) >> 3;
c += (d[i] & (1 << 2)) >> 2; c += (d[i] & (1 << 2)) >> 2;
c += (d[i] & (1 << 1)) >> 1;
c += d[i] & 1; c += d[i] & 1;
} }