diff options
author | 2019-10-15 23:47:51 +0000 | |
---|---|---|
committer | 2019-10-16 11:11:24 +0900 | |
commit | 46ba2abdfa95a26a86714dab386a72a3a5b706a5 (patch) | |
tree | 58980fd44362f365da3ab71a37d1fc61e58b40b2 /archive-tar.c | |
parent | graph: reduce duplication in `graph_insert_into_new_columns()` (diff) | |
download | tgif-46ba2abdfa95a26a86714dab386a72a3a5b706a5.tar.xz |
graph: remove `mapping_idx` and `graph_update_width()`
There's a duplication of logic between `graph_insert_into_new_columns()`
and `graph_update_width()`. `graph_insert_into_new_columns()` is called
repeatedly by `graph_update_columns()` with an `int *` that tracks the
offset into the `mapping` array where we should write the next value.
Each call to `graph_insert_into_new_columns()` effectively pushes one
column index and one "null" value (-1) onto the `mapping` array and
therefore increments `mapping_idx` by 2.
`graph_update_width()` duplicates this process: the `width` of the graph
is essentially the initial width of the `mapping` array before edges
begin collapsing. The `graph_update_width()` function's logic
effectively works out how many times `graph_insert_into_new_columns()`
was called based on the relationship of the current commit to the rest
of the graph.
I'm about to make some changes that make the assignment of values into
the `mapping` array more complicated. Rather than make
`graph_update_width()` more complicated at the same time, we can simply
remove this function and use `graph->width` to track the offset into the
`mapping` array as we're building it. This removes the duplication and
makes sure that `graph->width` is the same as the visual width of the
`mapping` array once `graph_update_columns()` is complete.
Signed-off-by: James Coglan <jcoglan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'archive-tar.c')
0 files changed, 0 insertions, 0 deletions