]> git.ipfire.org Git - thirdparty/git.git/commit
refs/iterator: implement seeking for ref-cache iterators
authorPatrick Steinhardt <ps@pks.im>
Wed, 12 Mar 2025 15:56:19 +0000 (16:56 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Mar 2025 18:31:20 +0000 (11:31 -0700)
commit84e656919cb7237f1b11a948974d0591d9d3434f
tree5d274a55963e3f188a706f526b78edf5351856de
parent53de20c931faabdb6fa9a30d949266b2a7471497
refs/iterator: implement seeking for ref-cache iterators

Implement seeking of ref-cache iterators. This is done by splitting most
of the logic to seek iterators out of `cache_ref_iterator_begin()` and
putting it into `cache_ref_iterator_seek()` so that we can reuse the
logic.

Note that we cannot use the optimization anymore where we return an
empty ref iterator when there aren't any references, as otherwise it
wouldn't be possible to reseek the iterator to a different prefix that
may exist. This shouldn't be much of a performance concern though as we
now start to bail out early in case `advance()` sees that there are no
more directories to be searched.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs/ref-cache.c