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>
This commit is contained in:
@ -78,7 +78,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
|
||||
for (p = get_all_packs(the_repository); p; p = p->next) {
|
||||
if (!p->pack_promisor)
|
||||
continue;
|
||||
if (find_pack_entry_one(oid->hash, p))
|
||||
if (find_pack_entry_one(oid, p))
|
||||
goto promisor_pack_found;
|
||||
}
|
||||
/*
|
||||
@ -144,7 +144,7 @@ no_promisor_pack_found:
|
||||
* are sure the ref is good and not sending it to
|
||||
* rev-list for verification.
|
||||
*/
|
||||
if (new_pack && find_pack_entry_one(oid->hash, new_pack))
|
||||
if (new_pack && find_pack_entry_one(oid, new_pack))
|
||||
continue;
|
||||
|
||||
if (fprintf(rev_list_in, "%s\n", oid_to_hex(oid)) < 0)
|
||||
|
Reference in New Issue
Block a user