Git fork

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>

authored by

Taylor Blau and committed by
Junio C Hamano
94c1addf 25163f50

+20
+19
ewah/bitmap.c
··· 261 261 return 1; 262 262 } 263 263 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 + 264 283 int bitmap_is_subset(struct bitmap *self, struct bitmap *other) 265 284 { 266 285 size_t common_size, i;
+1
ewah/ewok.h
··· 179 179 int bitmap_get(struct bitmap *self, size_t pos); 180 180 void bitmap_free(struct bitmap *self); 181 181 int bitmap_equals(struct bitmap *self, struct bitmap *other); 182 + int bitmap_equals_ewah(struct bitmap *self, struct ewah_bitmap *other); 182 183 183 184 /* 184 185 * Both `bitmap_is_subset()` and `ewah_bitmap_is_subset()` return 1 if the set