diff options
author | Abhishek Kumar <abhishekkumar8222@gmail.com> | 2020-06-17 12:14:11 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-06-18 00:37:52 +0300 |
commit | c752ad09c4ea479e8d54d08637cc0e5709723208 (patch) | |
tree | af0f1faa8d6e5149dec7d008a1370483c09ca151 /commit.c | |
parent | c49c82aa4c1036ba1629f73223cff53230e695f3 (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 <abhishekkumar8222@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r-- | commit.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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 */ |