Re: [PATCH v2 4/8] merge-ort: introduce wrappers for alternate tree traversal
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Mar 9, 2021, 23:06 UTC
- Message-ID
- <6bc2af18-dd16-5e41-1f5b-31ab73d7b9d3@gmail.com>
- In-Reply-To
- <6497050c00126bdeff6880e5a2a52cd7b8457513.1615248599.git.gitgitgadget@gmail.com>
On 3/8/2021 7:09 PM, Elijah Newren via GitGitGadget wrote:
Show 17 quoted lines
> From: Elijah Newren <newren@gmail.com> > > Add traverse_trees_wrapper() and traverse_trees_wrapper_callback() > functions. The former runs traverse_trees() with info->fn set to > traverse_trees_wrapper_callback, in order to simply save all the entries > without processing or recursing into any of them. This step allows > extra computation to be done (e.g. checking some condition across all > files) that can be used later. Then, after that is completed, it > iterates over all the saved entries and calls the original info->fn > callback with the saved data. > > Currently, this does nothing more than marginally slowing down the tree > traversal since we do not take advantage of the opportunity to compute > anything special in traverse_trees_wrapper_callback(), and thus the real > callback will be called identically as it would have been without this > extra wrapper. However, a subsequent commit will add some special > computation of some values that the real callback will be able to use.
I'm glad that you use the normal callback in the appropriate case.
It took me a couple reads to understand this last sentence, but I think I'm with you now.
Show 9 quoted lines
> + info->traverse_path = renames->callback_data_traverse_path;
> + info->fn = old_fn;
> + for (i = old_offset; i < renames->callback_data_nr; ++i) {
> + info->fn(n,
> + renames->callback_data[i].mask,
> + renames->callback_data[i].dirmask,
> + renames->callback_data[i].names,
> + info);
> +nit: extraneous newline.
Thanks, -Stolee