Skip to content

Commit 4a74414

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]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 901515d commit 4a74414

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
@@ -1622,25 +1622,29 @@ static void show_extended_objects(struct bitmap_index *bitmap_git,
16221622
}
16231623
}
16241624

1625-
static void init_type_iterator(struct ewah_iterator *it,
1625+
static void init_type_iterator(struct ewah_or_iterator *it,
16261626
struct bitmap_index *bitmap_git,
16271627
enum object_type type)
16281628
{
16291629
switch (type) {
16301630
case OBJ_COMMIT:
1631-
ewah_iterator_init(it, bitmap_git->commits);
1631+
ewah_or_iterator_init(it, bitmap_git->commits_all,
1632+
bitmap_git->base_nr);
16321633
break;
16331634

16341635
case OBJ_TREE:
1635-
ewah_iterator_init(it, bitmap_git->trees);
1636+
ewah_or_iterator_init(it, bitmap_git->trees_all,
1637+
bitmap_git->base_nr);
16361638
break;
16371639

16381640
case OBJ_BLOB:
1639-
ewah_iterator_init(it, bitmap_git->blobs);
1641+
ewah_or_iterator_init(it, bitmap_git->blobs_all,
1642+
bitmap_git->base_nr);
16401643
break;
16411644

16421645
case OBJ_TAG:
1643-
ewah_iterator_init(it, bitmap_git->tags);
1646+
ewah_or_iterator_init(it, bitmap_git->tags_all,
1647+
bitmap_git->base_nr);
16441648
break;
16451649

16461650
default:
@@ -1657,15 +1661,15 @@ static void show_objects_for_type(
16571661
size_t i = 0;
16581662
uint32_t offset;
16591663

1660-
struct ewah_iterator it;
1664+
struct ewah_or_iterator it;
16611665
eword_t filter;
16621666

16631667
struct bitmap *objects = bitmap_git->result;
16641668

16651669
init_type_iterator(&it, bitmap_git, object_type);
16661670

16671671
for (i = 0; i < objects->word_alloc &&
1668-
ewah_iterator_next(&filter, &it); i++) {
1672+
ewah_or_iterator_next(&filter, &it); i++) {
16691673
eword_t word = objects->words[i] & filter;
16701674
size_t pos = (i * BITS_IN_EWORD);
16711675

@@ -1707,6 +1711,8 @@ static void show_objects_for_type(
17071711
show_reach(&oid, object_type, 0, hash, pack, ofs);
17081712
}
17091713
}
1714+
1715+
ewah_or_iterator_free(&it);
17101716
}
17111717

17121718
static int in_bitmapped_pack(struct bitmap_index *bitmap_git,
@@ -1758,7 +1764,7 @@ static void filter_bitmap_exclude_type(struct bitmap_index *bitmap_git,
17581764
{
17591765
struct eindex *eindex = &bitmap_git->ext_index;
17601766
struct bitmap *tips;
1761-
struct ewah_iterator it;
1767+
struct ewah_or_iterator it;
17621768
eword_t mask;
17631769
uint32_t i;
17641770

@@ -1775,7 +1781,7 @@ static void filter_bitmap_exclude_type(struct bitmap_index *bitmap_git,
17751781
* packfile.
17761782
*/
17771783
for (i = 0, init_type_iterator(&it, bitmap_git, type);
1778-
i < to_filter->word_alloc && ewah_iterator_next(&mask, &it);
1784+
i < to_filter->word_alloc && ewah_or_iterator_next(&mask, &it);
17791785
i++) {
17801786
if (i < tips->word_alloc)
17811787
mask &= ~tips->words[i];
@@ -1795,6 +1801,7 @@ static void filter_bitmap_exclude_type(struct bitmap_index *bitmap_git,
17951801
bitmap_unset(to_filter, pos);
17961802
}
17971803

1804+
ewah_or_iterator_free(&it);
17981805
bitmap_free(tips);
17991806
}
18001807

@@ -1852,14 +1859,14 @@ static void filter_bitmap_blob_limit(struct bitmap_index *bitmap_git,
18521859
{
18531860
struct eindex *eindex = &bitmap_git->ext_index;
18541861
struct bitmap *tips;
1855-
struct ewah_iterator it;
1862+
struct ewah_or_iterator it;
18561863
eword_t mask;
18571864
uint32_t i;
18581865

18591866
tips = find_tip_objects(bitmap_git, tip_objects, OBJ_BLOB);
18601867

18611868
for (i = 0, init_type_iterator(&it, bitmap_git, OBJ_BLOB);
1862-
i < to_filter->word_alloc && ewah_iterator_next(&mask, &it);
1869+
i < to_filter->word_alloc && ewah_or_iterator_next(&mask, &it);
18631870
i++) {
18641871
eword_t word = to_filter->words[i] & mask;
18651872
unsigned offset;
@@ -1887,6 +1894,7 @@ static void filter_bitmap_blob_limit(struct bitmap_index *bitmap_git,
18871894
bitmap_unset(to_filter, pos);
18881895
}
18891896

1897+
ewah_or_iterator_free(&it);
18901898
bitmap_free(tips);
18911899
}
18921900

@@ -2502,12 +2510,12 @@ static uint32_t count_object_type(struct bitmap_index *bitmap_git,
25022510
struct eindex *eindex = &bitmap_git->ext_index;
25032511

25042512
uint32_t i = 0, count = 0;
2505-
struct ewah_iterator it;
2513+
struct ewah_or_iterator it;
25062514
eword_t filter;
25072515

25082516
init_type_iterator(&it, bitmap_git, type);
25092517

2510-
while (i < objects->word_alloc && ewah_iterator_next(&filter, &it)) {
2518+
while (i < objects->word_alloc && ewah_or_iterator_next(&filter, &it)) {
25112519
eword_t word = objects->words[i++] & filter;
25122520
count += ewah_bit_popcount64(word);
25132521
}
@@ -2519,6 +2527,8 @@ static uint32_t count_object_type(struct bitmap_index *bitmap_git,
25192527
count++;
25202528
}
25212529

2530+
ewah_or_iterator_free(&it);
2531+
25222532
return count;
25232533
}
25242534

@@ -3046,13 +3056,13 @@ static off_t get_disk_usage_for_type(struct bitmap_index *bitmap_git,
30463056
{
30473057
struct bitmap *result = bitmap_git->result;
30483058
off_t total = 0;
3049-
struct ewah_iterator it;
3059+
struct ewah_or_iterator it;
30503060
eword_t filter;
30513061
size_t i;
30523062

30533063
init_type_iterator(&it, bitmap_git, object_type);
30543064
for (i = 0; i < result->word_alloc &&
3055-
ewah_iterator_next(&filter, &it); i++) {
3065+
ewah_or_iterator_next(&filter, &it); i++) {
30563066
eword_t word = result->words[i] & filter;
30573067
size_t base = (i * BITS_IN_EWORD);
30583068
unsigned offset;
@@ -3093,6 +3103,8 @@ static off_t get_disk_usage_for_type(struct bitmap_index *bitmap_git,
30933103
}
30943104
}
30953105

3106+
ewah_or_iterator_free(&it);
3107+
30963108
return total;
30973109
}
30983110

0 commit comments

Comments
 (0)