diff mbox series

[08/23] ewah: implement bitmap_or()

Message ID dce9b6da0ad38da0a92b39d780d7b56f83d52950.1605123652.git.me@ttaylorr.com (mailing list archive)
State Superseded
Headers show
Series pack-bitmap: bitmap generation improvements | expand

Commit Message

Taylor Blau Nov. 11, 2020, 7:43 p.m. UTC
From: Jeff King <peff@peff.net>

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.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 ewah/bitmap.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Junio C Hamano Nov. 22, 2020, 8:34 p.m. UTC | #1
Taylor Blau <me@ttaylorr.com> writes:

> From: Jeff King <peff@peff.net>
>
> 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.

So we have had decl, no impl, but it did not matter because there
was no user?  Presumably we will see a real user soon in the series
;-)
Taylor Blau Nov. 23, 2020, 4:52 p.m. UTC | #2
On Sun, Nov 22, 2020 at 12:34:03PM -0800, Junio C Hamano wrote:
> Taylor Blau <me@ttaylorr.com> writes:
>
> > From: Jeff King <peff@peff.net>
> >
> > 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.
>
> So we have had decl, no impl, but it did not matter because there
> was no user?  Presumably we will see a real user soon in the series
> ;-)

Indeed :-). I added a note to this patch's log message to indicate that
a new/first caller would be appearing in a couple of patches after this
one.

Thanks,
Taylor
diff mbox series

Patch

diff --git a/ewah/bitmap.c b/ewah/bitmap.c
index 43a59d7fed..c3f8e7242b 100644
--- a/ewah/bitmap.c
+++ b/ewah/bitmap.c
@@ -127,6 +127,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;