]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'kk/commit-reach-optim' into jch
authorJunio C Hamano <gitster@pobox.com>
Fri, 29 May 2026 04:01:24 +0000 (13:01 +0900)
committerJunio C Hamano <gitster@pobox.com>
Fri, 29 May 2026 04:01:24 +0000 (13:01 +0900)
The check for non-stale commits in the priority queue used by
`paint_down_to_common` and `ahead_behind` has been optimized by
replacing an O(N) scan with an O(1) counter, yielding performance
improvements in repositories with wide histories.

* kk/commit-reach-optim:
  commit-reach: replace queue_has_nonstale() scan with O(1) tracking
  commit-reach: deduplicate queue entries in paint_down_to_common
  object.h: fix stale entries in object flag allocation table

1  2 
commit-reach.c

diff --cc commit-reach.c
index 9b3ea46d6f2824ccab3e2067c09ef34f08e1685c,2e86e1e80316a9ab4ee3875d6dadd61fdfce7020..5df471a313cf6be855b61fd9c06d2499e97bc7af
@@@ -54,10 -101,12 +101,12 @@@ static int paint_down_to_common(struct 
                                struct commit *one, int n,
                                struct commit **twos,
                                timestamp_t min_generation,
 -                              int ignore_missing_commits,
 +                              enum merge_base_flags mb_flags,
                                struct commit_list **result)
  {
-       struct prio_queue queue = { compare_commits_by_gen_then_commit_date };
+       struct nonstale_queue queue = {
+               { compare_commits_by_gen_then_commit_date }
+       };
        int i;
        timestamp_t last_gen = GENERATION_NUMBER_INFINITY;
        struct commit_list **tail = result;