Skip to content

Commit 3ed6751

Browse files
peffgitster
authored andcommitted
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 e127310 (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 <[email protected]> Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2e2d141 commit 3ed6751

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ewah/bitmap.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ void bitmap_and_not(struct bitmap *self, struct bitmap *other)
122122
self->words[i] &= ~other->words[i];
123123
}
124124

125+
void bitmap_or(struct bitmap *self, const struct bitmap *other)
126+
{
127+
size_t i;
128+
129+
bitmap_grow(self, other->word_alloc);
130+
for (i = 0; i < other->word_alloc; i++)
131+
self->words[i] |= other->words[i];
132+
}
133+
125134
void bitmap_or_ewah(struct bitmap *self, struct ewah_bitmap *other)
126135
{
127136
size_t original_size = self->word_alloc;

0 commit comments

Comments
 (0)