aboutsummaryrefslogtreecommitdiffstats
path: root/midx.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2021-09-11 22:43:26 +0200
committerJunio C Hamano <gitster@pobox.com>2021-09-12 16:14:32 -0700
commit09ef66179b943d03cbe0bea0603e5f40574695a1 (patch)
tree3cab775a4486a21314d5e536aae76c7a76be186e /midx.c
parent7407d733a4a99cf946cab0c82e03c41dbd305b7c (diff)
downloadgit-09ef66179b943d03cbe0bea0603e5f40574695a1.tar.gz
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.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/midx.c b/midx.c
index 8cb063023c..76322b713c 100644
--- a/midx.c
+++ b/midx.c
@@ -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;