Skip to content

Commit 5999b44

Browse files
ttaylorrgitster
authored andcommitted
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 <[email protected]> Acked-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e07af41 commit 5999b44

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

pack-bitmap.c

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,25 +1629,29 @@ static void show_extended_objects(struct bitmap_index *bitmap_git,
16291629
}
16301630
}
16311631

1632-
static void init_type_iterator(struct ewah_iterator *it,
1632+
static void init_type_iterator(struct ewah_or_iterator *it,
16331633
struct bitmap_index *bitmap_git,
16341634
enum object_type type)
16351635
{
16361636
switch (type) {
16371637
case OBJ_COMMIT:
1638-
ewah_iterator_init(it, bitmap_git->commits);
1638+
ewah_or_iterator_init(it, bitmap_git->commits_all,
1639+
bitmap_git->base_nr + 1);
16391640
break;
16401641

16411642
case OBJ_TREE:
1642-
ewah_iterator_init(it, bitmap_git->trees);
1643+
ewah_or_iterator_init(it, bitmap_git->trees_all,
1644+
bitmap_git->base_nr + 1);
16431645
break;
16441646

16451647
case OBJ_BLOB:
1646-
ewah_iterator_init(it, bitmap_git->blobs);
1648+
ewah_or_iterator_init(it, bitmap_git->blobs_all,
1649+
bitmap_git->base_nr + 1);
16471650
break;
16481651

16491652
case OBJ_TAG:
1650-
ewah_iterator_init(it, bitmap_git->tags);
1653+
ewah_or_iterator_init(it, bitmap_git->tags_all,
1654+
bitmap_git->base_nr + 1);
16511655
break;
16521656

16531657
default:
@@ -1664,15 +1668,15 @@ static void show_objects_for_type(
16641668
size_t i = 0;
16651669
uint32_t offset;
16661670

1667-
struct ewah_iterator it;
1671+
struct ewah_or_iterator it;
16681672
eword_t filter;
16691673

16701674
struct bitmap *objects = bitmap_git->result;
16711675

16721676
init_type_iterator(&it, bitmap_git, object_type);
16731677

16741678
for (i = 0; i < objects->word_alloc &&
1675-
ewah_iterator_next(&filter, &it); i++) {
1679+
ewah_or_iterator_next(&filter, &it); i++) {
16761680
eword_t word = objects->words[i] & filter;
16771681
size_t pos = (i * BITS_IN_EWORD);
16781682

@@ -1714,6 +1718,8 @@ static void show_objects_for_type(
17141718
show_reach(&oid, object_type, 0, hash, pack, ofs);
17151719
}
17161720
}
1721+
1722+
ewah_or_iterator_release(&it);
17171723
}
17181724

17191725
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,
17651771
{
17661772
struct eindex *eindex = &bitmap_git->ext_index;
17671773
struct bitmap *tips;
1768-
struct ewah_iterator it;
1774+
struct ewah_or_iterator it;
17691775
eword_t mask;
17701776
uint32_t i;
17711777

@@ -1782,7 +1788,7 @@ static void filter_bitmap_exclude_type(struct bitmap_index *bitmap_git,
17821788
* packfile.
17831789
*/
17841790
for (i = 0, init_type_iterator(&it, bitmap_git, type);
1785-
i < to_filter->word_alloc && ewah_iterator_next(&mask, &it);
1791+
i < to_filter->word_alloc && ewah_or_iterator_next(&mask, &it);
17861792
i++) {
17871793
if (i < tips->word_alloc)
17881794
mask &= ~tips->words[i];
@@ -1802,6 +1808,7 @@ static void filter_bitmap_exclude_type(struct bitmap_index *bitmap_git,
18021808
bitmap_unset(to_filter, pos);
18031809
}
18041810

1811+
ewah_or_iterator_release(&it);
18051812
bitmap_free(tips);
18061813
}
18071814

@@ -1862,14 +1869,14 @@ static void filter_bitmap_blob_limit(struct bitmap_index *bitmap_git,
18621869
{
18631870
struct eindex *eindex = &bitmap_git->ext_index;
18641871
struct bitmap *tips;
1865-
struct ewah_iterator it;
1872+
struct ewah_or_iterator it;
18661873
eword_t mask;
18671874
uint32_t i;
18681875

18691876
tips = find_tip_objects(bitmap_git, tip_objects, OBJ_BLOB);
18701877

18711878
for (i = 0, init_type_iterator(&it, bitmap_git, OBJ_BLOB);
1872-
i < to_filter->word_alloc && ewah_iterator_next(&mask, &it);
1879+
i < to_filter->word_alloc && ewah_or_iterator_next(&mask, &it);
18731880
i++) {
18741881
eword_t word = to_filter->words[i] & mask;
18751882
unsigned offset;
@@ -1897,6 +1904,7 @@ static void filter_bitmap_blob_limit(struct bitmap_index *bitmap_git,
18971904
bitmap_unset(to_filter, pos);
18981905
}
18991906

1907+
ewah_or_iterator_release(&it);
19001908
bitmap_free(tips);
19011909
}
19021910

@@ -2528,12 +2536,12 @@ static uint32_t count_object_type(struct bitmap_index *bitmap_git,
25282536
struct eindex *eindex = &bitmap_git->ext_index;
25292537

25302538
uint32_t i = 0, count = 0;
2531-
struct ewah_iterator it;
2539+
struct ewah_or_iterator it;
25322540
eword_t filter;
25332541

25342542
init_type_iterator(&it, bitmap_git, type);
25352543

2536-
while (i < objects->word_alloc && ewah_iterator_next(&filter, &it)) {
2544+
while (i < objects->word_alloc && ewah_or_iterator_next(&filter, &it)) {
25372545
eword_t word = objects->words[i++] & filter;
25382546
count += ewah_bit_popcount64(word);
25392547
}
@@ -2545,6 +2553,8 @@ static uint32_t count_object_type(struct bitmap_index *bitmap_git,
25452553
count++;
25462554
}
25472555

2556+
ewah_or_iterator_release(&it);
2557+
25482558
return count;
25492559
}
25502560

@@ -3077,13 +3087,13 @@ static off_t get_disk_usage_for_type(struct bitmap_index *bitmap_git,
30773087
{
30783088
struct bitmap *result = bitmap_git->result;
30793089
off_t total = 0;
3080-
struct ewah_iterator it;
3090+
struct ewah_or_iterator it;
30813091
eword_t filter;
30823092
size_t i;
30833093

30843094
init_type_iterator(&it, bitmap_git, object_type);
30853095
for (i = 0; i < result->word_alloc &&
3086-
ewah_iterator_next(&filter, &it); i++) {
3096+
ewah_or_iterator_next(&filter, &it); i++) {
30873097
eword_t word = result->words[i] & filter;
30883098
size_t base = (i * BITS_IN_EWORD);
30893099
unsigned offset;
@@ -3124,6 +3134,8 @@ static off_t get_disk_usage_for_type(struct bitmap_index *bitmap_git,
31243134
}
31253135
}
31263136

3137+
ewah_or_iterator_release(&it);
3138+
31273139
return total;
31283140
}
31293141

0 commit comments

Comments
 (0)