Skip to content

Commit f1cbd03

Browse files
peffgitster
authored andcommitted
pack-objects: use object_id in packlist_alloc()
The only caller of packlist_alloc() already has a "struct object_id", and we immediately copy the hash they pass us into our own object_id. Let's avoid the unnecessary round-trip to a raw sha1 pointer. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0dfed92 commit f1cbd03

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

builtin/pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ static void create_object_entry(const struct object_id *oid,
11471147
{
11481148
struct object_entry *entry;
11491149

1150-
entry = packlist_alloc(&to_pack, oid->hash, index_pos);
1150+
entry = packlist_alloc(&to_pack, oid, index_pos);
11511151
entry->hash = hash;
11521152
oe_set_type(entry, type);
11531153
if (exclude)

pack-objects.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ void prepare_packing_data(struct repository *r, struct packing_data *pdata)
153153
}
154154

155155
struct object_entry *packlist_alloc(struct packing_data *pdata,
156-
const unsigned char *sha1,
156+
const struct object_id *oid,
157157
uint32_t index_pos)
158158
{
159159
struct object_entry *new_entry;
@@ -177,7 +177,7 @@ struct object_entry *packlist_alloc(struct packing_data *pdata,
177177
new_entry = pdata->objects + pdata->nr_objects++;
178178

179179
memset(new_entry, 0, sizeof(*new_entry));
180-
hashcpy(new_entry->idx.oid.hash, sha1);
180+
oidcpy(&new_entry->idx.oid, oid);
181181

182182
if (pdata->index_size * 3 <= pdata->nr_objects * 4)
183183
rehash_objects(pdata);

pack-objects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static inline void packing_data_unlock(struct packing_data *pdata)
183183
}
184184

185185
struct object_entry *packlist_alloc(struct packing_data *pdata,
186-
const unsigned char *sha1,
186+
const struct object_id *oid,
187187
uint32_t index_pos);
188188

189189
struct object_entry *packlist_find(struct packing_data *pdata,

0 commit comments

Comments
 (0)