path: root/commit.c
diff options
authorAbhishek Kumar <>2020-06-17 09:14:11 (GMT)
committerJunio C Hamano <>2020-06-17 21:37:52 (GMT)
commitc752ad09c4ea479e8d54d08637cc0e5709723208 (patch)
treeaf0f1faa8d6e5149dec7d008a1370483c09ca151 /commit.c
parentc49c82aa4c1036ba1629f73223cff53230e695f3 (diff)
commit-graph: minimize commit_graph_data_slab access
In an earlier patch, multiple struct acccesses to `graph_pos` and `generation` were auto-converted to multiple method calls. Since the values are fixed and commit-slab access costly, we would be better off with storing the values as a local variable and reusing it. Signed-off-by: Abhishek Kumar <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'commit.c')
1 files changed, 4 insertions, 2 deletions
diff --git a/commit.c b/commit.c
index ed0917a..43d29a8 100644
--- a/commit.c
+++ b/commit.c
@@ -729,11 +729,13 @@ int compare_commits_by_author_date(const void *a_, const void *b_,
int compare_commits_by_gen_then_commit_date(const void *a_, const void *b_, void *unused)
const struct commit *a = a_, *b = b_;
+ const uint32_t generation_a = commit_graph_generation(a),
+ generation_b = commit_graph_generation(b);
/* newer commits first */
- if (commit_graph_generation(a) < commit_graph_generation(b))
+ if (generation_a < generation_b)
return 1;
- else if (commit_graph_generation(a) > commit_graph_generation(b))
+ else if (generation_a > generation_b)
return -1;
/* use date as a heuristic when generations are equal */