pack-bitmap.c: use `ewah_or_iterator` for type bitmap iterators
Now that we have initialized arrays for each bitmap layer's type bitmaps in the previous commit, adjust existing callers to use them in preparation for multi-layered bitmaps. Signed-off-by: Taylor Blau <me@ttaylorr.com> Acked-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
e07af41139
commit
5999b44fcb
|
|
@ -1629,25 +1629,29 @@ static void show_extended_objects(struct bitmap_index *bitmap_git,
|
|||
}
|
||||
}
|
||||
|
||||
static void init_type_iterator(struct ewah_iterator *it,
|
||||
static void init_type_iterator(struct ewah_or_iterator *it,
|
||||
struct bitmap_index *bitmap_git,
|
||||
enum object_type type)
|
||||
{
|
||||
switch (type) {
|
||||
case OBJ_COMMIT:
|
||||
ewah_iterator_init(it, bitmap_git->commits);
|
||||
ewah_or_iterator_init(it, bitmap_git->commits_all,
|
||||
bitmap_git->base_nr + 1);
|
||||
break;
|
||||
|
||||
case OBJ_TREE:
|
||||
ewah_iterator_init(it, bitmap_git->trees);
|
||||
ewah_or_iterator_init(it, bitmap_git->trees_all,
|
||||
bitmap_git->base_nr + 1);
|
||||
break;
|
||||
|
||||
case OBJ_BLOB:
|
||||
ewah_iterator_init(it, bitmap_git->blobs);
|
||||
ewah_or_iterator_init(it, bitmap_git->blobs_all,
|
||||
bitmap_git->base_nr + 1);
|
||||
break;
|
||||
|
||||
case OBJ_TAG:
|
||||
ewah_iterator_init(it, bitmap_git->tags);
|
||||
ewah_or_iterator_init(it, bitmap_git->tags_all,
|
||||
bitmap_git->base_nr + 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -1664,7 +1668,7 @@ static void show_objects_for_type(
|
|||
size_t i = 0;
|
||||
uint32_t offset;
|
||||
|
||||
struct ewah_iterator it;
|
||||
struct ewah_or_iterator it;
|
||||
eword_t filter;
|
||||
|
||||
struct bitmap *objects = bitmap_git->result;
|
||||
|
|
@ -1672,7 +1676,7 @@ static void show_objects_for_type(
|
|||
init_type_iterator(&it, bitmap_git, object_type);
|
||||
|
||||
for (i = 0; i < objects->word_alloc &&
|
||||
ewah_iterator_next(&filter, &it); i++) {
|
||||
ewah_or_iterator_next(&filter, &it); i++) {
|
||||
eword_t word = objects->words[i] & filter;
|
||||
size_t pos = (i * BITS_IN_EWORD);
|
||||
|
||||
|
|
@ -1714,6 +1718,8 @@ static void show_objects_for_type(
|
|||
show_reach(&oid, object_type, 0, hash, pack, ofs);
|
||||
}
|
||||
}
|
||||
|
||||
ewah_or_iterator_release(&it);
|
||||
}
|
||||
|
||||
static int in_bitmapped_pack(struct bitmap_index *bitmap_git,
|
||||
|
|
@ -1765,7 +1771,7 @@ static void filter_bitmap_exclude_type(struct bitmap_index *bitmap_git,
|
|||
{
|
||||
struct eindex *eindex = &bitmap_git->ext_index;
|
||||
struct bitmap *tips;
|
||||
struct ewah_iterator it;
|
||||
struct ewah_or_iterator it;
|
||||
eword_t mask;
|
||||
uint32_t i;
|
||||
|
||||
|
|
@ -1782,7 +1788,7 @@ static void filter_bitmap_exclude_type(struct bitmap_index *bitmap_git,
|
|||
* packfile.
|
||||
*/
|
||||
for (i = 0, init_type_iterator(&it, bitmap_git, type);
|
||||
i < to_filter->word_alloc && ewah_iterator_next(&mask, &it);
|
||||
i < to_filter->word_alloc && ewah_or_iterator_next(&mask, &it);
|
||||
i++) {
|
||||
if (i < tips->word_alloc)
|
||||
mask &= ~tips->words[i];
|
||||
|
|
@ -1802,6 +1808,7 @@ static void filter_bitmap_exclude_type(struct bitmap_index *bitmap_git,
|
|||
bitmap_unset(to_filter, pos);
|
||||
}
|
||||
|
||||
ewah_or_iterator_release(&it);
|
||||
bitmap_free(tips);
|
||||
}
|
||||
|
||||
|
|
@ -1862,14 +1869,14 @@ static void filter_bitmap_blob_limit(struct bitmap_index *bitmap_git,
|
|||
{
|
||||
struct eindex *eindex = &bitmap_git->ext_index;
|
||||
struct bitmap *tips;
|
||||
struct ewah_iterator it;
|
||||
struct ewah_or_iterator it;
|
||||
eword_t mask;
|
||||
uint32_t i;
|
||||
|
||||
tips = find_tip_objects(bitmap_git, tip_objects, OBJ_BLOB);
|
||||
|
||||
for (i = 0, init_type_iterator(&it, bitmap_git, OBJ_BLOB);
|
||||
i < to_filter->word_alloc && ewah_iterator_next(&mask, &it);
|
||||
i < to_filter->word_alloc && ewah_or_iterator_next(&mask, &it);
|
||||
i++) {
|
||||
eword_t word = to_filter->words[i] & mask;
|
||||
unsigned offset;
|
||||
|
|
@ -1897,6 +1904,7 @@ static void filter_bitmap_blob_limit(struct bitmap_index *bitmap_git,
|
|||
bitmap_unset(to_filter, pos);
|
||||
}
|
||||
|
||||
ewah_or_iterator_release(&it);
|
||||
bitmap_free(tips);
|
||||
}
|
||||
|
||||
|
|
@ -2528,12 +2536,12 @@ static uint32_t count_object_type(struct bitmap_index *bitmap_git,
|
|||
struct eindex *eindex = &bitmap_git->ext_index;
|
||||
|
||||
uint32_t i = 0, count = 0;
|
||||
struct ewah_iterator it;
|
||||
struct ewah_or_iterator it;
|
||||
eword_t filter;
|
||||
|
||||
init_type_iterator(&it, bitmap_git, type);
|
||||
|
||||
while (i < objects->word_alloc && ewah_iterator_next(&filter, &it)) {
|
||||
while (i < objects->word_alloc && ewah_or_iterator_next(&filter, &it)) {
|
||||
eword_t word = objects->words[i++] & filter;
|
||||
count += ewah_bit_popcount64(word);
|
||||
}
|
||||
|
|
@ -2545,6 +2553,8 @@ static uint32_t count_object_type(struct bitmap_index *bitmap_git,
|
|||
count++;
|
||||
}
|
||||
|
||||
ewah_or_iterator_release(&it);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
|
@ -3077,13 +3087,13 @@ static off_t get_disk_usage_for_type(struct bitmap_index *bitmap_git,
|
|||
{
|
||||
struct bitmap *result = bitmap_git->result;
|
||||
off_t total = 0;
|
||||
struct ewah_iterator it;
|
||||
struct ewah_or_iterator it;
|
||||
eword_t filter;
|
||||
size_t i;
|
||||
|
||||
init_type_iterator(&it, bitmap_git, object_type);
|
||||
for (i = 0; i < result->word_alloc &&
|
||||
ewah_iterator_next(&filter, &it); i++) {
|
||||
ewah_or_iterator_next(&filter, &it); i++) {
|
||||
eword_t word = result->words[i] & filter;
|
||||
size_t base = (i * BITS_IN_EWORD);
|
||||
unsigned offset;
|
||||
|
|
@ -3124,6 +3134,8 @@ static off_t get_disk_usage_for_type(struct bitmap_index *bitmap_git,
|
|||
}
|
||||
}
|
||||
|
||||
ewah_or_iterator_release(&it);
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue