]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit-graph: move slab-clearing to close_commit_graph()
authorJeff King <peff@peff.net>
Tue, 3 Oct 2023 20:27:52 +0000 (16:27 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Oct 2023 21:28:24 +0000 (14:28 -0700)
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 957ba814bf (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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit-graph.c

index 5e8a3a50851f108e380806f52915af786b627a37..dc54ef4776ffeeed8de13801f60ffff2d8478ece 100644 (file)
@@ -728,13 +728,13 @@ static void close_commit_graph_one(struct commit_graph *g)
        if (!g)
                return;
 
-       clear_commit_graph_data_slab(&commit_graph_data_slab);
        close_commit_graph_one(g->base_graph);
        free_commit_graph(g);
 }
 
 void close_commit_graph(struct raw_object_store *o)
 {
+       clear_commit_graph_data_slab(&commit_graph_data_slab);
        close_commit_graph_one(o->commit_graph);
        o->commit_graph = NULL;
 }