aboutsummaryrefslogtreecommitdiff
path: root/ewah/bitmap.c
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2024-05-23 17:27:02 -0400
committerJunio C Hamano <gitster@pobox.com>2024-05-24 11:40:43 -0700
commit0481cbf912e23d96076e3a7e149e76a0327a7a70 (patch)
treecb93fe48ff1e4b5532e94ad0b735d1d41a87de36 /ewah/bitmap.c
parent955747b4daaac33a11b1f5362227f1839cff41d3 (diff)
downloadgit-0481cbf912e23d96076e3a7e149e76a0327a7a70.tar.xz
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>
Diffstat (limited to 'ewah/bitmap.c')
-rw-r--r--ewah/bitmap.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/ewah/bitmap.c b/ewah/bitmap.c
index d352fec54c..dc2ca190f1 100644
--- a/ewah/bitmap.c
+++ b/ewah/bitmap.c
@@ -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;