On 11/1/24 9:12 AM, karthik nayak wrote:
"Derrick Stolee via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes:
From: Derrick Stolee <stolee@xxxxxxxxx>
The walk_objects_by_path() method initializes these structures and
starts walking commits from the given rev_info struct. The commits are
used to find the list of root trees which populate the start of our
depth-first search.
Isn't this more of breadth-first search? Reading through the code, the
algorithm seems something like:
- For each commit in list of commits (from rev_info)
- Tackle each root tree, add root path to the stack.
- For each path in stack left
- Call the callback provided by client.
- Find all its first level children, add each to the stack.
So wouldn't this go through the tree in level by level basis? Making it
a BFS?
While we are adding all children to the stack, we only pop off the top
of the stack, making it a DFS. (We do visit the paths in reverse-
lexicographic order, though.)
To make it a BFS, we would need to visit the paths in the order they
are added to the list. Instead, we visit them in Last-In First-Out
order.
I initially had built it as a BFS, but ran into memory issues when
running it on very large repos.
Thanks,
-Stolee