]> git.ipfire.org Git - thirdparty/git.git/commit
reftable/block: store block pointer in the block iterator
authorPatrick Steinhardt <ps@pks.im>
Mon, 7 Apr 2025 13:16:22 +0000 (15:16 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 7 Apr 2025 21:53:11 +0000 (14:53 -0700)
commit156d79cef0de565408e41f840bbda87114367977
treeca4c34aac1d17912c06258b36c8a304ec6d1cfbd
parent655e18d6b4f845090b0ba4761105b32726893ecb
reftable/block: store block pointer in the block iterator

The block iterator requires access to a bunch of data from the
underlying `reftable_block` that it is iterating over. This data is
stored by copying over relevant data into a separate set of variables.
This has multiple downsides:

  - We require more storage space than necessary. This is more of a
    theoretical issue as we shouldn't ever have many blocks.

  - We have to perform more bookkeeping, and the variable names are
    inconsistent across the two data structures. This can lead to some
    confusion.

  - The lifetime of the block iterator is tied to the block anyway, but
    we hide that a bit by only storing pointers pointing into the block.

There isn't really any good reason why we rip out parts of the block
instead of storing a pointer to the block itself.

Refactor the code to do so. Despite being simpler, it also allows us to
decouple the lifetime of the block iterator from seeking in a subsequent
commit.

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