diff options
author | SZEDER Gábor <szeder.dev@gmail.com> | 2020-06-05 13:00:31 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-06-08 12:28:49 -0700 |
commit | bb4d60e5d536009e0c97bfa7f464416c29c04c81 (patch) | |
tree | 6b8f4d5d63a194fffca504f2929a0a2835b979f6 /po | |
parent | commit-graph: simplify parse_commit_graph() #2 (diff) | |
download | tgif-bb4d60e5d536009e0c97bfa7f464416c29c04c81.tar.xz |
commit-graph: simplify write_commit_graph_file() #1
In write_commit_graph_file() one block of code fills the array of
chunk IDs, another block of code fills the array of chunk offsets,
then the chunk IDs and offsets are written to the Chunk Lookup table,
and finally a third block of code writes the actual chunks. In case
of optional chunks like Extra Edge List and Base Graphs List there is
also a condition checking whether that chunk is necessary/desired, and
that same condition is repeated in all those three blocks of code.
This patch series is about to add more optional chunks, so there would
be even more repeated conditions.
Those chunk offsets are relative to the beginning of the file, so they
inherently depend on the size of the Chunk Lookup table, which in turn
depends on the number of chunks that are to be written to the
commit-graph file. IOW at the time we set the first chunk's ID we
can't yet know its offset, because we don't yet know how many chunks
there are.
Simplify this by initially filling an array of chunk sizes, not
offsets, and calculate the offsets based on the chunk sizes only
later, while we are writing the Chunk Lookup table. This way we can
fill the arrays of chunk IDs and sizes in one go, eliminating one set
of repeated conditions.
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>
Diffstat (limited to 'po')
0 files changed, 0 insertions, 0 deletions