Skip to content

Commit ac6d45d

Browse files
peffgitster
authored andcommitted
commit-graph: move slab-clearing to close_commit_graph()
When closing and freeing a commit-graph, the main entry point is close_commit_graph(), which then uses close_commit_graph_one() to recurse through the base_graph links and free each one. Commit 957ba81 (commit-graph: when closing the graph, also release the slab, 2021-09-08) put the call to clear the slab into the recursive function, but this is pointless: there's only a single global slab variable. It works OK in practice because clearing the slab is idempotent, but it makes the code harder to reason about and refactor. Move it into the parent function so it's only called once (and there are no other direct callers of the recursive close_commit_graph_one(), so we are not hurting them). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 716a6b2 commit ac6d45d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

commit-graph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,13 +728,13 @@ static void close_commit_graph_one(struct commit_graph *g)
728728
if (!g)
729729
return;
730730

731-
clear_commit_graph_data_slab(&commit_graph_data_slab);
732731
close_commit_graph_one(g->base_graph);
733732
free_commit_graph(g);
734733
}
735734

736735
void close_commit_graph(struct raw_object_store *o)
737736
{
737+
clear_commit_graph_data_slab(&commit_graph_data_slab);
738738
close_commit_graph_one(o->commit_graph);
739739
o->commit_graph = NULL;
740740
}

0 commit comments

Comments
 (0)