pack-bitmap: consolidate `find_object_pos()` success path
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
May 27, 2026 at 15:55 UTC
ece3465d44157157a03eb7cd5de955e552e7831c
1 file changed
+9
-9
pack-bitmap-write.c
+9
-9
@@ -217,6 +217,7 @@ static uint32_t find_object_pos(struct bitmap_writer *writer,
217
const struct object_id *oid, int *found)
218
{
219
struct object_entry *entry;
220
+ uint32_t pos;
221
222
entry = packlist_find(writer->to_pack, oid);
223
if (entry) {
@@ -224,23 +225,22 @@ static uint32_t find_object_pos(struct bitmap_writer *writer,
225
if (writer->midx)
226
base_objects = writer->midx->num_objects +
227
writer->midx->num_objects_in_base;
227
-
228
- if (found)
229
- *found = 1;
230
- return oe_in_pack_pos(writer->to_pack, entry) + base_objects;
228
+ pos = oe_in_pack_pos(writer->to_pack, entry) + base_objects;
229
} else if (writer->midx) {
232
- uint32_t at, pos;
230
+ uint32_t at;
231
232
if (!bsearch_midx(oid, writer->midx, &at))
233
goto missing;
234
if (midx_to_pack_pos(writer->midx, at, &pos) < 0)
235
goto missing;
238
-
239
- if (found)
240
- *found = 1;
241
- return pos;
236
+ } else {
237
+ goto missing;
238
}
239
240
+ if (found)
241
+ *found = 1;
242
+ return pos;
243
+
244
missing:
245
if (found)
246
*found = 0;