delta-islands: convert island_marks khash to use oids
All of the users of this map have an actual "struct object_id" rather than a bare sha1. Let's use the more descriptive type (and get one step closer to dropping khash_sha1 entirely). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jun 20, 2019 at 03:41 UTC
f8e56da97df846e67508eaf26d11fd007e1b75c1
1 file changed
+11
-11
delta-islands.c
+11
-11
@@ -22,7 +22,7 @@
22
23
KHASH_INIT(str, const char *, void *, 1, kh_str_hash_func, kh_str_hash_equal)
24
25
-static khash_sha1 *island_marks;
25
+static kh_oid_map_t *island_marks;
26
static unsigned island_counter;
27
static unsigned island_counter_core;
28
@@ -105,7 +105,7 @@ int in_same_island(const struct object_id *trg_oid, const struct object_id *src_
105
* If we don't have a bitmap for the target, we can delta it
106
* against anything -- it's not an important object
107
*/
108
- trg_pos = kh_get_sha1(island_marks, trg_oid->hash);
108
+ trg_pos = kh_get_oid_map(island_marks, *trg_oid);
109
if (trg_pos >= kh_end(island_marks))
110
return 1;
111
@@ -113,7 +113,7 @@ int in_same_island(const struct object_id *trg_oid, const struct object_id *src_
113
* if the source (our delta base) doesn't have a bitmap,
114
* we don't want to base any deltas on it!
115
*/
116
- src_pos = kh_get_sha1(island_marks, src_oid->hash);
116
+ src_pos = kh_get_oid_map(island_marks, *src_oid);
117
if (src_pos >= kh_end(island_marks))
118
return 0;
119
@@ -129,11 +129,11 @@ int island_delta_cmp(const struct object_id *a, const struct object_id *b)
129
if (!island_marks)
130
return 0;
131
132
- a_pos = kh_get_sha1(island_marks, a->hash);
132
+ a_pos = kh_get_oid_map(island_marks, *a);
133
if (a_pos < kh_end(island_marks))
134
a_bitmap = kh_value(island_marks, a_pos);
135
136
- b_pos = kh_get_sha1(island_marks, b->hash);
136
+ b_pos = kh_get_oid_map(island_marks, *b);
137
if (b_pos < kh_end(island_marks))
138
b_bitmap = kh_value(island_marks, b_pos);
139
@@ -154,7 +154,7 @@ static struct island_bitmap *create_or_get_island_marks(struct object *obj)
154
khiter_t pos;
155
int hash_ret;
156
157
- pos = kh_put_sha1(island_marks, obj->oid.hash, &hash_ret);
157
+ pos = kh_put_oid_map(island_marks, obj->oid, &hash_ret);
158
if (hash_ret)
159
kh_value(island_marks, pos) = island_bitmap_new(NULL);
160
@@ -167,7 +167,7 @@ static void set_island_marks(struct object *obj, struct island_bitmap *marks)
167
khiter_t pos;
168
int hash_ret;
169
170
- pos = kh_put_sha1(island_marks, obj->oid.hash, &hash_ret);
170
+ pos = kh_put_oid_map(island_marks, obj->oid, &hash_ret);
171
if (hash_ret) {
172
/*
173
* We don't have one yet; make a copy-on-write of the
@@ -279,7 +279,7 @@ void resolve_tree_islands(struct repository *r,
279
struct name_entry entry;
280
khiter_t pos;
281
282
- pos = kh_get_sha1(island_marks, ent->idx.oid.hash);
282
+ pos = kh_get_oid_map(island_marks, ent->idx.oid);
283
if (pos >= kh_end(island_marks))
284
continue;
285
@@ -456,7 +456,7 @@ static void deduplicate_islands(struct repository *r)
456
457
void load_delta_islands(struct repository *r)
458
{
459
- island_marks = kh_init_sha1();
459
+ island_marks = kh_init_oid_map();
460
remote_islands = kh_init_str();
461
462
git_config(island_config_callback, NULL);
@@ -468,7 +468,7 @@ void load_delta_islands(struct repository *r)
468
469
void propagate_island_marks(struct commit *commit)
470
{
471
- khiter_t pos = kh_get_sha1(island_marks, commit->object.oid.hash);
471
+ khiter_t pos = kh_get_oid_map(island_marks, commit->object.oid);
472
473
if (pos < kh_end(island_marks)) {
474
struct commit_list *p;
@@ -490,7 +490,7 @@ int compute_pack_layers(struct packing_data *to_pack)
490
491
for (i = 0; i < to_pack->nr_objects; ++i) {
492
struct object_entry *entry = &to_pack->objects[i];
493
- khiter_t pos = kh_get_sha1(island_marks, entry->idx.oid.hash);
493
+ khiter_t pos = kh_get_oid_map(island_marks, entry->idx.oid);
494
495
oe_set_layer(to_pack, entry, 1);
496