[PATCH 4/8] pack-bitmap: consolidate `find_object_pos()` success path
- From
Taylor Blau <me@ttaylorr.com>
- Date
- May 19, 2026, 16:12 UTC
- Message-ID
- <c9a560660949c53575a9b1e81160d25212a1f484.1779207127.git.me@ttaylorr.com>
- In-Reply-To
- <cover.1779207127.git.me@ttaylorr.com>
Both sides of `find_object_pos()` report success in the same way by setting the optional `found` out-parameter and return the resolved bitmap position.
Prepare for adding more bookkeeping around object-position lookups by storing the result in a local `pos` variable and sharing the success return path between the packlist and MIDX cases.
Signed-off-by: Taylor Blau <me@ttaylorr.com> --- pack-bitmap-write.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c index 651ad467469..6483fdc7daf 100644 --- a/pack-bitmap-write.c +++ b/pack-bitmap-write.c @@ -224,23 +224,22 @@ static uint32_t find_object_pos(struct bitmap_writer *writer, if (writer->midx) base_objects = writer->midx->num_objects + writer->midx->num_objects_in_base; - - if (found) - *found = 1; - return oe_in_pack_pos(writer->to_pack, entry) + base_objects; + pos = oe_in_pack_pos(writer->to_pack, entry) + base_objects; } else if (writer->midx) { - uint32_t at, pos; + uint32_t at; if (!bsearch_midx(oid, writer->midx, &at)) goto missing; if (midx_to_pack_pos(writer->midx, at, &pos) < 0) goto missing; - - if (found) - *found = 1; - return pos; + } else { + goto missing; } + if (found) + *found = 1; + return pos; + missing: if (found) *found = 0;
-- 2.54.0.rc1.84.g30ce254312c