]> git.ipfire.org Git - thirdparty/git.git/commit
pack-revindex: factor out `midx_key_to_pack_pos()` helper
authorTaylor Blau <me@ttaylorr.com>
Thu, 14 Dec 2023 22:24:28 +0000 (17:24 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Dec 2023 22:38:08 +0000 (14:38 -0800)
commite1bfe30c4dd29a1a30569d04432d73675e497e86
treec53dc9d441a7721ba71c61aecd07d2dd0170f4ed
parentb1e3333068247ddd44021a0b69457c249ddee7a1
pack-revindex: factor out `midx_key_to_pack_pos()` helper

The `midx_to_pack_pos()` function implements a binary search over
objects in the MIDX between lexical and pseudo-pack order. It does this
by taking in an index into the lexical order (i.e. the same argument
you'd use for `nth_midxed_object_id()` and similar) and spits out a
position in the pseudo-pack order.

This works for all callers, since they currently all are translating
from lexical order to pseudo-pack order. But future callers may want to
translate a known (offset, pack_id) tuple into an index into the
psuedo-pack order, without knowing where that (offset, pack_id) tuple
appears in lexical order.

Prepare for implementing a function that translates between a (offset,
pack_id) tuple into an index into the psuedo-pack order by extracting a
helper function which does just that, and then reimplementing
midx_to_pack_pos() in terms of it.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pack-revindex.c