]> git.ipfire.org Git - thirdparty/git.git/commitdiff
ewah: implement bitmap_or()
authorJeff King <peff@peff.net>
Tue, 8 Dec 2020 22:03:46 +0000 (17:03 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 8 Dec 2020 22:48:16 +0000 (14:48 -0800)
We have a function to bitwise-OR an ewah into an uncompressed bitmap,
but not to OR two uncompressed bitmaps. Let's add it.

Interestingly, we have a public header declaration going back to
e1273106f6 (ewah: compressed bitmap implementation, 2013-11-14), but the
function was never implemented. That was all OK since there were no
users of 'bitmap_or()', but a first caller will be added in a couple of
patches.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
ewah/bitmap.c

index 6f9e5c529bfeaa4d57e50c0a7ae584e4f384db29..0a3502603ffb752a51e569384984c05137c270e8 100644 (file)
@@ -122,6 +122,15 @@ void bitmap_and_not(struct bitmap *self, struct bitmap *other)
                self->words[i] &= ~other->words[i];
 }
 
+void bitmap_or(struct bitmap *self, const struct bitmap *other)
+{
+       size_t i;
+
+       bitmap_grow(self, other->word_alloc);
+       for (i = 0; i < other->word_alloc; i++)
+               self->words[i] |= other->words[i];
+}
+
 void bitmap_or_ewah(struct bitmap *self, struct ewah_bitmap *other)
 {
        size_t original_size = self->word_alloc;