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>
This commit is contained in:
committed by
Junio C Hamano
parent
c49c82aa4c
commit
c752ad09c4
6
commit.c
6
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 */
|
||||
|
||||
Reference in New Issue
Block a user