diff options
author | René Scharfe <l.s.r@web.de> | 2021-09-11 22:43:26 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-09-12 16:14:32 -0700 |
commit | 09ef66179b943d03cbe0bea0603e5f40574695a1 (patch) | |
tree | 3cab775a4486a21314d5e536aae76c7a76be186e /midx.c | |
parent | packfile: convert has_packed_and_bad() to object_id (diff) | |
download | tgif-09ef66179b943d03cbe0bea0603e5f40574695a1.tar.xz |
packfile: use oidset for bad objects
Store the object ID of broken pack entries in an oidset instead of
keeping only their hashes in an unsorted array. The resulting code is
shorter and easier to read. It also handles the (hopefully) very rare
case of having a high number of bad objects better.
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'midx.c')
-rw-r--r-- | midx.c | 10 |
1 files changed, 3 insertions, 7 deletions
@@ -307,13 +307,9 @@ int fill_midx_entry(struct repository * r, if (!is_pack_valid(p)) return 0; - if (p->num_bad_objects) { - uint32_t i; - for (i = 0; i < p->num_bad_objects; i++) - if (hasheq(oid->hash, - p->bad_object_sha1 + the_hash_algo->rawsz * i)) - return 0; - } + if (oidset_size(&p->bad_objects) && + oidset_contains(&p->bad_objects, oid)) + return 0; e->offset = nth_midxed_offset(m, pos); e->p = p; |