pack-objects: use object_id in packlist_alloc()
authorJeff King <peff@peff.net>
Thu, 5 Sep 2019 22:52:25 +0000 (18:52 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 6 Sep 2019 18:03:39 +0000 (11:03 -0700)
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>
builtin/pack-objects.c
pack-objects.c
pack-objects.h
index 76ce9069467e06545652a70040b79316f0a87fb9..dc2a7e9ac0126f47fde8a479657c1faeea440074 100644 (file)
@@ -1147,7 +1147,7 @@ static void create_object_entry(const struct object_id *oid,
 {
        struct object_entry *entry;
 
-       entry = packlist_alloc(&to_pack, oid->hash, index_pos);
+       entry = packlist_alloc(&to_pack, oid, index_pos);
        entry->hash = hash;
        oe_set_type(entry, type);
        if (exclude)
index 52560293b6268b792803e5b2c89b3a96840c0bf9..c1df08df1ad27f2c684fd925cf7f564e109075b9 100644 (file)
@@ -153,7 +153,7 @@ void prepare_packing_data(struct repository *r, struct packing_data *pdata)
 }
 
 struct object_entry *packlist_alloc(struct packing_data *pdata,
-                                   const unsigned char *sha1,
+                                   const struct object_id *oid,
                                    uint32_t index_pos)
 {
        struct object_entry *new_entry;
@@ -177,7 +177,7 @@ struct object_entry *packlist_alloc(struct packing_data *pdata,
        new_entry = pdata->objects + pdata->nr_objects++;
 
        memset(new_entry, 0, sizeof(*new_entry));
-       hashcpy(new_entry->idx.oid.hash, sha1);
+       oidcpy(&new_entry->idx.oid, oid);
 
        if (pdata->index_size * 3 <= pdata->nr_objects * 4)
                rehash_objects(pdata);
index 857d43850b6258696d506a23cabd1adc187d8159..47bf7ebf8665d036e2dacb5cc69840cecfda3382 100644 (file)
@@ -183,7 +183,7 @@ static inline void packing_data_unlock(struct packing_data *pdata)
 }
 
 struct object_entry *packlist_alloc(struct packing_data *pdata,
-                                   const unsigned char *sha1,
+                                   const struct object_id *oid,
                                    uint32_t index_pos);
 
 struct object_entry *packlist_find(struct packing_data *pdata,