Skip to content

Commit 94c1add

Browse files
ttaylorrgitster
authored andcommitted
ewah: bitmap_equals_ewah()
Prepare to reuse existing pseudo-merge bitmaps by implementing a `bitmap_equals_ewah()` helper. This helper will be used to see if a raw bitmap (containing the set of parents for some pseudo-merge) is equal to any existing pseudo-merge's commits bitmap (which are stored as EWAH-compressed bitmaps on disk). Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 25163f5 commit 94c1add

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

ewah/bitmap.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,25 @@ int bitmap_equals(struct bitmap *self, struct bitmap *other)
261261
return 1;
262262
}
263263

264+
int bitmap_equals_ewah(struct bitmap *self, struct ewah_bitmap *other)
265+
{
266+
struct ewah_iterator it;
267+
eword_t word;
268+
size_t i = 0;
269+
270+
ewah_iterator_init(&it, other);
271+
272+
while (ewah_iterator_next(&word, &it))
273+
if (word != (i < self->word_alloc ? self->words[i++] : 0))
274+
return 0;
275+
276+
for (; i < self->word_alloc; i++)
277+
if (self->words[i])
278+
return 0;
279+
280+
return 1;
281+
}
282+
264283
int bitmap_is_subset(struct bitmap *self, struct bitmap *other)
265284
{
266285
size_t common_size, i;

ewah/ewok.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ void bitmap_unset(struct bitmap *self, size_t pos);
179179
int bitmap_get(struct bitmap *self, size_t pos);
180180
void bitmap_free(struct bitmap *self);
181181
int bitmap_equals(struct bitmap *self, struct bitmap *other);
182+
int bitmap_equals_ewah(struct bitmap *self, struct ewah_bitmap *other);
182183

183184
/*
184185
* Both `bitmap_is_subset()` and `ewah_bitmap_is_subset()` return 1 if the set

0 commit comments

Comments
 (0)