Re: [PATCH v2 19/20] files_pack_refs(): use reference iteration
- From
Michael Haggerty <mhagger@alum.mit.edu>
- Date
- Apr 16, 2017, 06:13 UTC
- Message-ID
- <c29c0e5f-e0eb-2be3-3ebf-0a8f838fc5b1@alum.mit.edu>
- In-Reply-To
- <CACsJy8DAFUQnjkLnaXD0aM_97_E_7F_=fMeJb2Azigt2Pv0gTw@mail.gmail.com>
On 04/07/2017 01:51 PM, Duy Nguyen wrote:
Show 8 quoted lines
> On Fri, Mar 31, 2017 at 9:11 PM, Michael Haggerty <mhagger@alum.mit.edu> wrote: >> Use reference iteration rather than do_for_each_entry_in_dir() in the >> definition of files_pack_refs(). > > A "why" is missing here. My guess is readability/maintainability > because it's easier to follow the code with iterator design, than the > callback one? No maintaining data in struct pack_refs_cb_data is also > very nice.
You're right. I'll improve the commit message to something like
files_pack_refs(): use reference iteration
Use reference iteration rather than `do_for_each_entry_in_dir()` in the definition of `files_pack_refs()`. This makes the code shorter and easier to follow, because the logic can be inline rather than spread between the main function and a callback function, and it removes the need to use `pack_refs_cb_data` to preserve intermediate state.
This removes the last callers of `entry_resolves_to_object()` and `get_loose_ref_dir()`, so delete those functions.
Thanks, Michael