]> git.ipfire.org Git - thirdparty/git.git/commit
commit-graph: simplify parse_commit_graph() #2
authorSZEDER Gábor <szeder.dev@gmail.com>
Fri, 5 Jun 2020 13:00:30 +0000 (13:00 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 Jun 2020 19:28:49 +0000 (12:28 -0700)
commit5cfa438a76f7f67f34f6f758b62943261ded1fb5
tree71522f20164715f850153d741cadaaebc7f5c4b3
parent2ad4f1a7c43cac4ba52cff56f9090d3322c67224
commit-graph: simplify parse_commit_graph() #2

The Chunk Lookup table stores the chunks' starting offset in the
commit-graph file, not their sizes.  Consequently, the size of a chunk
can only be calculated by subtracting its offset from the offset of
the subsequent chunk (or that of the terminating label).  This is
currenly implemented in a bit complicated way: as we iterate over the
entries of the Chunk Lookup table, we check the id of each chunk and
store its starting offset, then we check the id of the last seen chunk
and calculate its size using its previously saved offset.  At the
moment there is only one chunk for which we calculate its size, but
this patch series will add more, and the repeated chunk id checks are
not that pretty.

Instead let's read ahead the offset of the next chunk on each
iteration, so we can calculate the size of each chunk right away,
right where we store its starting offset.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit-graph.c