Skip to content

Commit f8e56da

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8fbb558 commit f8e56da

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

delta-islands.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
KHASH_INIT(str, const char *, void *, 1, kh_str_hash_func, kh_str_hash_equal)
2424

25-
static khash_sha1 *island_marks;
25+
static kh_oid_map_t *island_marks;
2626
static unsigned island_counter;
2727
static unsigned island_counter_core;
2828

@@ -105,15 +105,15 @@ int in_same_island(const struct object_id *trg_oid, const struct object_id *src_
105105
* If we don't have a bitmap for the target, we can delta it
106106
* against anything -- it's not an important object
107107
*/
108-
trg_pos = kh_get_sha1(island_marks, trg_oid->hash);
108+
trg_pos = kh_get_oid_map(island_marks, *trg_oid);
109109
if (trg_pos >= kh_end(island_marks))
110110
return 1;
111111

112112
/*
113113
* if the source (our delta base) doesn't have a bitmap,
114114
* we don't want to base any deltas on it!
115115
*/
116-
src_pos = kh_get_sha1(island_marks, src_oid->hash);
116+
src_pos = kh_get_oid_map(island_marks, *src_oid);
117117
if (src_pos >= kh_end(island_marks))
118118
return 0;
119119

@@ -129,11 +129,11 @@ int island_delta_cmp(const struct object_id *a, const struct object_id *b)
129129
if (!island_marks)
130130
return 0;
131131

132-
a_pos = kh_get_sha1(island_marks, a->hash);
132+
a_pos = kh_get_oid_map(island_marks, *a);
133133
if (a_pos < kh_end(island_marks))
134134
a_bitmap = kh_value(island_marks, a_pos);
135135

136-
b_pos = kh_get_sha1(island_marks, b->hash);
136+
b_pos = kh_get_oid_map(island_marks, *b);
137137
if (b_pos < kh_end(island_marks))
138138
b_bitmap = kh_value(island_marks, b_pos);
139139

@@ -154,7 +154,7 @@ static struct island_bitmap *create_or_get_island_marks(struct object *obj)
154154
khiter_t pos;
155155
int hash_ret;
156156

157-
pos = kh_put_sha1(island_marks, obj->oid.hash, &hash_ret);
157+
pos = kh_put_oid_map(island_marks, obj->oid, &hash_ret);
158158
if (hash_ret)
159159
kh_value(island_marks, pos) = island_bitmap_new(NULL);
160160

@@ -167,7 +167,7 @@ static void set_island_marks(struct object *obj, struct island_bitmap *marks)
167167
khiter_t pos;
168168
int hash_ret;
169169

170-
pos = kh_put_sha1(island_marks, obj->oid.hash, &hash_ret);
170+
pos = kh_put_oid_map(island_marks, obj->oid, &hash_ret);
171171
if (hash_ret) {
172172
/*
173173
* We don't have one yet; make a copy-on-write of the
@@ -279,7 +279,7 @@ void resolve_tree_islands(struct repository *r,
279279
struct name_entry entry;
280280
khiter_t pos;
281281

282-
pos = kh_get_sha1(island_marks, ent->idx.oid.hash);
282+
pos = kh_get_oid_map(island_marks, ent->idx.oid);
283283
if (pos >= kh_end(island_marks))
284284
continue;
285285

@@ -456,7 +456,7 @@ static void deduplicate_islands(struct repository *r)
456456

457457
void load_delta_islands(struct repository *r)
458458
{
459-
island_marks = kh_init_sha1();
459+
island_marks = kh_init_oid_map();
460460
remote_islands = kh_init_str();
461461

462462
git_config(island_config_callback, NULL);
@@ -468,7 +468,7 @@ void load_delta_islands(struct repository *r)
468468

469469
void propagate_island_marks(struct commit *commit)
470470
{
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);
472472

473473
if (pos < kh_end(island_marks)) {
474474
struct commit_list *p;
@@ -490,7 +490,7 @@ int compute_pack_layers(struct packing_data *to_pack)
490490

491491
for (i = 0; i < to_pack->nr_objects; ++i) {
492492
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);
494494

495495
oe_set_layer(to_pack, entry, 1);
496496

0 commit comments

Comments
 (0)