diff options
| author | Taylor Blau <me@ttaylorr.com> | 2024-05-23 17:27:18 -0400 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-05-24 11:40:44 -0700 |
| commit | 94c1addf862619250a1584c05a43f80f1c8d7d72 (patch) | |
| tree | 8bdbccc81708ee6358478a2470d6ac5493d2ecd4 /ewah/bitmap.c | |
| parent | 25163f50a238087f5157e73eb645ddc5b2d133d7 (diff) | |
| download | git-94c1addf862619250a1584c05a43f80f1c8d7d72.tar.gz | |
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 <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'ewah/bitmap.c')
| -rw-r--r-- | ewah/bitmap.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/ewah/bitmap.c b/ewah/bitmap.c index dc2ca190f1..55928dada8 100644 --- a/ewah/bitmap.c +++ b/ewah/bitmap.c @@ -261,6 +261,25 @@ int bitmap_equals(struct bitmap *self, struct bitmap *other) return 1; } +int bitmap_equals_ewah(struct bitmap *self, struct ewah_bitmap *other) +{ + struct ewah_iterator it; + eword_t word; + size_t i = 0; + + ewah_iterator_init(&it, other); + + while (ewah_iterator_next(&word, &it)) + if (word != (i < self->word_alloc ? self->words[i++] : 0)) + return 0; + + for (; i < self->word_alloc; i++) + if (self->words[i]) + return 0; + + return 1; +} + int bitmap_is_subset(struct bitmap *self, struct bitmap *other) { size_t common_size, i; |
