Re: [PATCH 1/6] path-walk: introduce an object walk by path
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Nov 1, 2024, 13:44 UTC
- Message-ID
- <541b89c7-5e4b-4251-a8e7-3a9cde381064@gmail.com>
- In-Reply-To
- <CAOLa=ZQnEL7i=QbqjHYjpjWv_uhG=u+1w1FUKTMgkfNYd3fefg@mail.gmail.com>
On 11/1/24 9:12 AM, karthik nayak wrote:
Show 20 quoted lines
> "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes: > >> From: Derrick Stolee <stolee@gmail.com> >> >> 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