]> git.ipfire.org Git - thirdparty/git.git/commit
reftable/stack: reuse buffers when reloading stack
authorPatrick Steinhardt <ps@pks.im>
Mon, 11 Dec 2023 09:07:50 +0000 (10:07 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 11 Dec 2023 15:23:16 +0000 (07:23 -0800)
commitd779996a1087747886853f4e73cff920c09ab1a2
tree90686911c1328cb140de679f27480e8bff5469c3
parent5c086453ff32a2ca07ac455594d59a9943b5d113
reftable/stack: reuse buffers when reloading stack

In `reftable_stack_reload_once()` we iterate over all the tables added
to the stack in order to figure out whether any of the tables needs to
be reloaded. We use a set of buffers in this context to compute the
paths of these tables, but discard those buffers on every iteration.
This is quite wasteful given that we do not need to transfer ownership
of the allocated buffer outside of the loop.

Refactor the code to instead reuse the buffers to reduce the number of
allocations we need to do. Note that we do not have to manually reset
the buffer because `stack_filename()` does this for us already.

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