diff options
author | Derrick Stolee <dstolee@microsoft.com> | 2018-04-06 19:09:32 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-04-11 10:47:16 +0900 |
commit | 891435d55da80ca3654b19834481205be6bdfe33 (patch) | |
tree | fddc1768c14c6567f7be5205bf808d8bae86981a /builtin | |
parent | 2d5792f0716605ff0059fe4b5c865d6821c0161e (diff) | |
download | git-891435d55da80ca3654b19834481205be6bdfe33.tar.gz |
treewide: rename tree to maybe_tree
Using the commit-graph file to walk commit history removes the large
cost of parsing commits during the walk. This exposes a performance
issue: lookup_tree() takes a large portion of the computation time,
even when Git never uses those trees.
In anticipation of lazy-loading these trees, rename the 'tree' member
of struct commit to 'maybe_tree'. This serves two purposes: it hints
at the future role of possibly being NULL even if the commit has a
valid tree, and it allows for unambiguous transformation from simple
member access (i.e. commit->maybe_tree) to method access.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/checkout.c | 12 | ||||
-rw-r--r-- | builtin/diff.c | 2 | ||||
-rw-r--r-- | builtin/fast-export.c | 6 | ||||
-rw-r--r-- | builtin/log.c | 4 | ||||
-rw-r--r-- | builtin/reflog.c | 2 |
5 files changed, 13 insertions, 13 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c index a52af2e507..ca6aa29794 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -484,7 +484,7 @@ static int merge_working_tree(const struct checkout_opts *opts, resolve_undo_clear(); if (opts->force) { - ret = reset_tree(new_branch_info->commit->tree, opts, 1, writeout_error); + ret = reset_tree(new_branch_info->commit->maybe_tree, opts, 1, writeout_error); if (ret) return ret; } else { @@ -570,18 +570,18 @@ static int merge_working_tree(const struct checkout_opts *opts, o.verbosity = 0; work = write_tree_from_memory(&o); - ret = reset_tree(new_branch_info->commit->tree, opts, 1, + ret = reset_tree(new_branch_info->commit->maybe_tree, opts, 1, writeout_error); if (ret) return ret; o.ancestor = old_branch_info->name; o.branch1 = new_branch_info->name; o.branch2 = "local"; - ret = merge_trees(&o, new_branch_info->commit->tree, work, - old_branch_info->commit->tree, &result); + ret = merge_trees(&o, new_branch_info->commit->maybe_tree, work, + old_branch_info->commit->maybe_tree, &result); if (ret < 0) exit(128); - ret = reset_tree(new_branch_info->commit->tree, opts, 0, + ret = reset_tree(new_branch_info->commit->maybe_tree, opts, 0, writeout_error); strbuf_release(&o.obuf); if (ret) @@ -1002,7 +1002,7 @@ static int parse_branchname_arg(int argc, const char **argv, *source_tree = parse_tree_indirect(rev); } else { parse_commit_or_die(new_branch_info->commit); - *source_tree = new_branch_info->commit->tree; + *source_tree = new_branch_info->commit->maybe_tree; } if (!*source_tree) /* case (1): want a tree */ diff --git a/builtin/diff.c b/builtin/diff.c index 16bfb22f73..34f18a5f3f 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -398,7 +398,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix) if (!obj) die(_("invalid object '%s' given."), name); if (obj->type == OBJ_COMMIT) - obj = &((struct commit *)obj)->tree->object; + obj = &((struct commit *)obj)->maybe_tree->object; if (obj->type == OBJ_TREE) { obj->flags |= flags; diff --git a/builtin/fast-export.c b/builtin/fast-export.c index 27b2cc138e..91e526b30d 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -578,11 +578,11 @@ static void handle_commit(struct commit *commit, struct rev_info *rev, get_object_mark(&commit->parents->item->object) != 0 && !full_tree) { parse_commit_or_die(commit->parents->item); - diff_tree_oid(&commit->parents->item->tree->object.oid, - &commit->tree->object.oid, "", &rev->diffopt); + diff_tree_oid(&commit->parents->item->maybe_tree->object.oid, + &commit->maybe_tree->object.oid, "", &rev->diffopt); } else - diff_root_tree_oid(&commit->tree->object.oid, + diff_root_tree_oid(&commit->maybe_tree->object.oid, "", &rev->diffopt); /* Export the referenced blobs, and remember the marks. */ diff --git a/builtin/log.c b/builtin/log.c index 46b4ca13e5..a1fbc608bc 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -1064,8 +1064,8 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout, diff_setup_done(&opts); - diff_tree_oid(&origin->tree->object.oid, - &head->tree->object.oid, + diff_tree_oid(&origin->maybe_tree->object.oid, + &head->maybe_tree->object.oid, "", &opts); diffcore_std(&opts); diff_flush(&opts); diff --git a/builtin/reflog.c b/builtin/reflog.c index ac3dcd7a51..29d80a35a1 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -153,7 +153,7 @@ static int commit_is_complete(struct commit *commit) for (i = 0; i < found.nr; i++) { struct commit *c = (struct commit *)found.objects[i].item; - if (!tree_is_complete(&c->tree->object.oid)) { + if (!tree_is_complete(&c->maybe_tree->object.oid)) { is_incomplete = 1; c->object.flags |= INCOMPLETE; } |