]> git.ipfire.org Git - thirdparty/git.git/commit
reftable/merged: reuse buffer to compute record keys
authorPatrick Steinhardt <ps@pks.im>
Mon, 11 Dec 2023 09:08:03 +0000 (10:08 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 11 Dec 2023 15:23:16 +0000 (07:23 -0800)
commit829231dc203f777a32ebdbbaf66e7661a21ac74a
tree2a87e741cd205217d022aaa39ee6dd38cfacd5f1
parent9abda98149e0f164ac0532fc6ca89b337049b9c3
reftable/merged: reuse buffer to compute record keys

When iterating over entries in the merged iterator's queue, we compute
the key of each of the entries and write it into a buffer. We do not
reuse the buffer though and thus re-allocate it on every iteration,
which is wasteful given that we never transfer ownership of the
allocated bytes outside of the loop.

Refactor the code to reuse the buffer. This also fixes a potential
memory leak when `merged_iter_advance_subiter()` returns an error.

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