summary refs log tree commit diff
path: root/ewah
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2020-12-08 17:03:46 -0500
committerJunio C Hamano <gitster@pobox.com>2020-12-08 14:48:16 -0800
commit3ed675101aad3dcc948ad0e1d41e55d65e693740 (patch)
treed43980fe61148ec22a1a17693dff2d4ff41fd727 /ewah
parent2e2d141afdaa2b086ac5d4228de0dd0003eb69ff (diff)
ewah: implement bitmap_or()
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>
Diffstat (limited to 'ewah')
-rw-r--r--ewah/bitmap.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/ewah/bitmap.c b/ewah/bitmap.c
index 6f9e5c529b..0a3502603f 100644
--- a/ewah/bitmap.c
+++ b/ewah/bitmap.c
@@ -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;