diff options
author | Jeff King <peff@peff.net> | 2024-10-25 09:06:06 +0200 |
---|---|---|
committer | Taylor Blau <me@ttaylorr.com> | 2024-10-25 23:35:46 +0200 |
commit | 479ab76c9ffbd35585a1506ac5c99fe218df70b9 (patch) | |
tree | 9e3218c9573b0b45ca5e90e4e5660cfa18592b6c /packfile.h | |
parent | packfile: convert find_sha1_pack() to use object_id (diff) | |
download | git-479ab76c9ffbd35585a1506ac5c99fe218df70b9.tar.xz git-479ab76c9ffbd35585a1506ac5c99fe218df70b9.zip |
packfile: use object_id in find_pack_entry_one()
The main function we use to search a pack index for an object is
find_pack_entry_one(). That function still takes a bare pointer to the
hash, despite the fact that its underlying bsearch_pack() function needs
an object_id struct. And so we end up making an extra copy of the hash
into the struct just to do a lookup.
As it turns out, all callers but one already have such an object_id. So
we can just take a pointer to that struct and use it directly. This
avoids the extra copy and provides a more type-safe interface.
The one exception is get_delta_base() in packfile.c, when we are chasing
a REF_DELTA from inside the pack (and thus we have a pointer directly to
the mmap'd pack memory, not a struct). We can just bump the hashcpy()
from inside find_pack_entry_one() to this one caller that needs it.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Diffstat (limited to 'packfile.h')
-rw-r--r-- | packfile.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/packfile.h b/packfile.h index 3baffa940c..08f88a7ff5 100644 --- a/packfile.h +++ b/packfile.h @@ -154,10 +154,10 @@ int nth_packed_object_id(struct object_id *, struct packed_git *, uint32_t n); off_t nth_packed_object_offset(const struct packed_git *, uint32_t n); /* - * If the object named sha1 is present in the specified packfile, + * If the object named by oid is present in the specified packfile, * return its offset within the packfile; otherwise, return 0. */ -off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *); +off_t find_pack_entry_one(const struct object_id *oid, struct packed_git *); int is_pack_valid(struct packed_git *); void *unpack_entry(struct repository *r, struct packed_git *, off_t, enum object_type *, unsigned long *); |