ewah: implement ewah_bitmap_popcount()
Some of the pseudo-merge test helpers (which will be introduced in the following commit) will want to indicate the total number of commits in or objects reachable from a pseudo-merge. Implement a popcount() function that operates on EWAH bitmaps to quickly determine how many bits are set in each of the respective bitmaps. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
955747b4da
commit
0481cbf912
@ -212,6 +212,20 @@ size_t bitmap_popcount(struct bitmap *self)
|
||||
return count;
|
||||
}
|
||||
|
||||
size_t ewah_bitmap_popcount(struct ewah_bitmap *self)
|
||||
{
|
||||
struct ewah_iterator it;
|
||||
eword_t word;
|
||||
size_t count = 0;
|
||||
|
||||
ewah_iterator_init(&it, self);
|
||||
|
||||
while (ewah_iterator_next(&word, &it))
|
||||
count += ewah_bit_popcount64(word);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int bitmap_is_empty(struct bitmap *self)
|
||||
{
|
||||
size_t i;
|
||||
|
Reference in New Issue
Block a user