Skip to content

Commit

Permalink
more consistent naming for population count of words
Browse files Browse the repository at this point in the history
  • Loading branch information
ilanschnell committed Feb 20, 2023
1 parent c3f4b48 commit 58f68e2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bitarray/_bitarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ count(bitarrayobject *self, Py_ssize_t a, Py_ssize_t b)
assert(wa <= wb && 64 * wa - a < 64 && b - 64 * wb < 64);

cnt += count(self, a, 64 * wa);
cnt += popcount_words(WBUFF(self) + wa, wb - wa);
cnt += popcnt_words(WBUFF(self) + wa, wb - wa);
cnt += count(self, 64 * wb, b);
}
else if (n >= 8) {
Expand Down
6 changes: 3 additions & 3 deletions bitarray/_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ count_n_core(bitarrayobject *a, Py_ssize_t n, int vi)
/* by counting big blocks we save comparisons and updates */
#define BLOCK_BITS 4096 /* block size: 4096 bits = 64 words */
while (i + BLOCK_BITS < nbits) {
m = popcount_words(wbuff + i / 64, BLOCK_BITS / 64);
m = popcnt_words(wbuff + i / 64, BLOCK_BITS / 64);
if (!vi)
m = BLOCK_BITS - m;
if (t + m >= n)
Expand Down Expand Up @@ -1038,7 +1038,7 @@ count_from_word(bitarrayobject *a, Py_ssize_t i)

if (64 * i >= nbits)
return 0;
cnt += popcount_words(WBUFF(a) + i, nbits / 64 - i);
cnt += popcnt_words(WBUFF(a) + i, nbits / 64 - i);
if (nbits % 64)
cnt += popcnt_64(zlw(a));
return cnt;
Expand Down Expand Up @@ -1129,7 +1129,7 @@ sc_calc_rts(bitarrayobject *a)
assert((m + 1) * SEGSIZE <= Py_SIZE(a));

if (memcmp(buff, zeros, SEGSIZE)) /* segment has not only zeros */
cnt += popcount_words((uint64_t *) buff, SEGSIZE / 8);
cnt += popcnt_words((uint64_t *) buff, SEGSIZE / 8);
}
res[c_seg] = cnt;

Expand Down
2 changes: 1 addition & 1 deletion bitarray/bitarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ popcnt_64(uint64_t x)

/* population count of `n` words starting from `w` */
static inline Py_ssize_t
popcount_words(uint64_t *w, Py_ssize_t n)
popcnt_words(uint64_t *w, Py_ssize_t n)
{
Py_ssize_t cnt = 0;

Expand Down

0 comments on commit 58f68e2

Please sign in to comment.