Skip to content

Commit

Permalink
cache-tree: avoid an unnecessary check
Browse files Browse the repository at this point in the history
The first thing the `parse_tree()` function does is to return early if
the tree has already been parsed. Therefore we do not need to guard the
`parse_tree()` call behind a check of that flag.

As of time of writing, there are no other instances of this in Git's
code bases: whenever the `parsed` flag guards a `parse_tree()` call, it
guards more than just that call.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Feb 22, 2024
1 parent 9e4dc94 commit 91dc4cc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cache-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ static void prime_cache_tree_rec(struct repository *r,
struct cache_tree_sub *sub;
struct tree *subtree = lookup_tree(r, &entry.oid);

if (!subtree->object.parsed && parse_tree(subtree) < 0)
if (parse_tree(subtree) < 0)
exit(128);
sub = cache_tree_sub(it, entry.path);
sub->cache_tree = cache_tree();
Expand Down

0 comments on commit 91dc4cc

Please sign in to comment.