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>
Taylor Blau committed
Mar 20, 2025 at 13:57 UTC
5999b44fcbe1e1638960314c65723c60be6aeb9c
1 file changed
+27
-15
pack-bitmap.c
+27
-15
@@ -1629,25 +1629,29 @@ static void show_extended_objects(struct bitmap_index *bitmap_git,
1629
}
1630
}
1631
1632
-static void init_type_iterator(struct ewah_iterator *it,
1632
+static void init_type_iterator(struct ewah_or_iterator *it,
1633
struct bitmap_index *bitmap_git,
1634
enum object_type type)
1635
{
1636
switch (type) {
1637
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);
1640
break;
1641
1642
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);
1645
break;
1646
1647
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);
1650
break;
1651
1652
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);
1655
break;
1656
1657
default:
@@ -1664,7 +1668,7 @@ static void show_objects_for_type(
1668
size_t i = 0;
1669
uint32_t offset;
1670
1667
- struct ewah_iterator it;
1671
+ struct ewah_or_iterator it;
1672
eword_t filter;
1673
1674
struct bitmap *objects = bitmap_git->result;
@@ -1672,7 +1676,7 @@ static void show_objects_for_type(
1676
init_type_iterator(&it, bitmap_git, object_type);
1677
1678
for (i = 0; i < objects->word_alloc &&
1675
- ewah_iterator_next(&filter, &it); i++) {
1679
+ ewah_or_iterator_next(&filter, &it); i++) {
1680
eword_t word = objects->words[i] & filter;
1681
size_t pos = (i * BITS_IN_EWORD);
1682
@@ -1714,6 +1718,8 @@ static void show_objects_for_type(
1718
show_reach(&oid, object_type, 0, hash, pack, ofs);
1719
}
1720
}
1721
+
1722
+ ewah_or_iterator_release(&it);
1723
}
1724
1725
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,
1771
{
1772
struct eindex *eindex = &bitmap_git->ext_index;
1773
struct bitmap *tips;
1768
- struct ewah_iterator it;
1774
+ struct ewah_or_iterator it;
1775
eword_t mask;
1776
uint32_t i;
1777
@@ -1782,7 +1788,7 @@ static void filter_bitmap_exclude_type(struct bitmap_index *bitmap_git,
1788
* packfile.
1789
*/
1790
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);
1792
i++) {
1793
if (i < tips->word_alloc)
1794
mask &= ~tips->words[i];
@@ -1802,6 +1808,7 @@ static void filter_bitmap_exclude_type(struct bitmap_index *bitmap_git,
1808
bitmap_unset(to_filter, pos);
1809
}
1810
1811
+ ewah_or_iterator_release(&it);
1812
bitmap_free(tips);
1813
}
1814
@@ -1862,14 +1869,14 @@ static void filter_bitmap_blob_limit(struct bitmap_index *bitmap_git,
1869
{
1870
struct eindex *eindex = &bitmap_git->ext_index;
1871
struct bitmap *tips;
1865
- struct ewah_iterator it;
1872
+ struct ewah_or_iterator it;
1873
eword_t mask;
1874
uint32_t i;
1875
1876
tips = find_tip_objects(bitmap_git, tip_objects, OBJ_BLOB);
1877
1878
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);
1880
i++) {
1881
eword_t word = to_filter->words[i] & mask;
1882
unsigned offset;
@@ -1897,6 +1904,7 @@ static void filter_bitmap_blob_limit(struct bitmap_index *bitmap_git,
1904
bitmap_unset(to_filter, pos);
1905
}
1906
1907
+ ewah_or_iterator_release(&it);
1908
bitmap_free(tips);
1909
}
1910
@@ -2528,12 +2536,12 @@ static uint32_t count_object_type(struct bitmap_index *bitmap_git,
2536
struct eindex *eindex = &bitmap_git->ext_index;
2537
2538
uint32_t i = 0, count = 0;
2531
- struct ewah_iterator it;
2539
+ struct ewah_or_iterator it;
2540
eword_t filter;
2541
2542
init_type_iterator(&it, bitmap_git, type);
2543
2536
- while (i < objects->word_alloc && ewah_iterator_next(&filter, &it)) {
2544
+ while (i < objects->word_alloc && ewah_or_iterator_next(&filter, &it)) {
2545
eword_t word = objects->words[i++] & filter;
2546
count += ewah_bit_popcount64(word);
2547
}
@@ -2545,6 +2553,8 @@ static uint32_t count_object_type(struct bitmap_index *bitmap_git,
2553
count++;
2554
}
2555
2556
+ ewah_or_iterator_release(&it);
2557
+
2558
return count;
2559
}
2560
@@ -3077,13 +3087,13 @@ static off_t get_disk_usage_for_type(struct bitmap_index *bitmap_git,
3087
{
3088
struct bitmap *result = bitmap_git->result;
3089
off_t total = 0;
3080
- struct ewah_iterator it;
3090
+ struct ewah_or_iterator it;
3091
eword_t filter;
3092
size_t i;
3093
3094
init_type_iterator(&it, bitmap_git, object_type);
3095
for (i = 0; i < result->word_alloc &&
3086
- ewah_iterator_next(&filter, &it); i++) {
3096
+ ewah_or_iterator_next(&filter, &it); i++) {
3097
eword_t word = result->words[i] & filter;
3098
size_t base = (i * BITS_IN_EWORD);
3099
unsigned offset;
@@ -3124,6 +3134,8 @@ static off_t get_disk_usage_for_type(struct bitmap_index *bitmap_git,
3134
}
3135
}
3136
3137
+ ewah_or_iterator_release(&it);
3138
+
3139
return total;
3140
}
3141