Commit 10103da
committed
commit-reach: add general graph traversal find_reachable()
Add find_reachable(), a generalization of the memoized DFS in
can_all_from_reach_with_flag().
The benefits are two-fold:
1. make the code more uniform - fewer core graph traversals
to maintain and reason about.
2. optimization for ref-filter --contains
Most converted callers get equal or slightly better performance,
since this standardizes on the generally "best" implementation.
The big win is ref-filter --contains/--no-contains.
Instead of calling commit_contains() for each ref, we batch it
into batched calls to find_reachable(), changing the time complexity
from O(N * D) to O(D + N) where D is the reachable graph depth and
N is the number of refs.
Signed-off-by: Kristofer Karlsson <krka@spotify.com>1 parent 9ac3f19 commit 10103da
6 files changed
Lines changed: 236 additions & 288 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | 74 | | |
76 | 75 | | |
77 | 76 | | |
| |||
0 commit comments