midx: inline nth_midxed_pack_entry()
fill_midx_entry() finds the position of an object ID and passes it to nth_midxed_pack_entry(), which uses the position to look up the object ID for its own purposes. Inline the latter into the former to avoid that lookup. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Sep 11, 2021 at 22:39 UTC
893b5635059a7e47b042073bc69ca0c5d9d15dc2
1 file changed
+9
-20
midx.c
+9
-20
@@ -276,14 +276,18 @@ uint32_t nth_midxed_pack_int_id(struct multi_pack_index *m, uint32_t pos)
276
(off_t)pos * MIDX_CHUNK_OFFSET_WIDTH);
277
}
278
279
-static int nth_midxed_pack_entry(struct repository *r,
280
- struct multi_pack_index *m,
281
- struct pack_entry *e,
282
- uint32_t pos)
279
+int fill_midx_entry(struct repository * r,
280
+ const struct object_id *oid,
281
+ struct pack_entry *e,
282
+ struct multi_pack_index *m)
283
{
284
+ uint32_t pos;
285
uint32_t pack_int_id;
286
struct packed_git *p;
287
288
+ if (!bsearch_midx(oid, m, &pos))
289
+ return 0;
290
+
291
if (pos >= m->num_objects)
292
return 0;
293
@@ -305,10 +309,8 @@ static int nth_midxed_pack_entry(struct repository *r,
309
310
if (p->num_bad_objects) {
311
uint32_t i;
308
- struct object_id oid;
309
- nth_midxed_object_oid(&oid, m, pos);
312
for (i = 0; i < p->num_bad_objects; i++)
311
- if (hasheq(oid.hash,
313
+ if (hasheq(oid->hash,
314
p->bad_object_sha1 + the_hash_algo->rawsz * i))
315
return 0;
316
}
@@ -319,19 +321,6 @@ static int nth_midxed_pack_entry(struct repository *r,
321
return 1;
322
}
323
322
-int fill_midx_entry(struct repository * r,
323
- const struct object_id *oid,
324
- struct pack_entry *e,
325
- struct multi_pack_index *m)
326
-{
327
- uint32_t pos;
328
-
329
- if (!bsearch_midx(oid, m, &pos))
330
- return 0;
331
-
332
- return nth_midxed_pack_entry(r, m, e, pos);
333
-}
334
-
324
/* Match "foo.idx" against either "foo.pack" _or_ "foo.idx". */
325
static int cmp_idx_or_pack_name(const char *idx_or_pack_name,
326
const char *idx_name)