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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Sep 5, 2019 at 18:52 UTC
f1cbd033e201a18c7175bc6509b48d6243e79739
3 files changed
+4
-4
builtin/pack-objects.c
+1
-1
@@ -1147,7 +1147,7 @@ static void create_object_entry(const struct object_id *oid,
1147
{
1148
struct object_entry *entry;
1149
1150
- entry = packlist_alloc(&to_pack, oid->hash, index_pos);
1150
+ entry = packlist_alloc(&to_pack, oid, index_pos);
1151
entry->hash = hash;
1152
oe_set_type(entry, type);
1153
if (exclude)
pack-objects.c
+2
-2
@@ -153,7 +153,7 @@ void prepare_packing_data(struct repository *r, struct packing_data *pdata)
153
}
154
155
struct object_entry *packlist_alloc(struct packing_data *pdata,
156
- const unsigned char *sha1,
156
+ const struct object_id *oid,
157
uint32_t index_pos)
158
{
159
struct object_entry *new_entry;
@@ -177,7 +177,7 @@ struct object_entry *packlist_alloc(struct packing_data *pdata,
177
new_entry = pdata->objects + pdata->nr_objects++;
178
179
memset(new_entry, 0, sizeof(*new_entry));
180
- hashcpy(new_entry->idx.oid.hash, sha1);
180
+ oidcpy(&new_entry->idx.oid, oid);
181
182
if (pdata->index_size * 3 <= pdata->nr_objects * 4)
183
rehash_objects(pdata);
pack-objects.h
+1
-1
@@ -183,7 +183,7 @@ static inline void packing_data_unlock(struct packing_data *pdata)
183
}
184
185
struct object_entry *packlist_alloc(struct packing_data *pdata,
186
- const unsigned char *sha1,
186
+ const struct object_id *oid,
187
uint32_t index_pos);
188
189
struct object_entry *packlist_find(struct packing_data *pdata,