Re: [PATCH v2 1/2] dir: consider worktree config in path recursion
- From
Elijah Newren <newren@gmail.com>
- Date
- May 24, 2022, 14:29 UTC
- Message-ID
- <CABPp-BGXRzYCvyM38dEUvQ125+VtRu++7L9UiRz98u+1=Lov7A@mail.gmail.com>
- In-Reply-To
- <xmqq7d6sm3e0.fsf@gitster.g>
On Wed, May 11, 2022 at 9:37 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 9 quoted lines
> > Goss Geppert <gg.oss.dev@gmail.com> writes: > > > diff --git a/dir.c b/dir.c > > index f2b0f24210..a1886e61a3 100644 > > --- a/dir.c > > +++ b/dir.c > > @@ -1893,9 +1893,31 @@ static enum path_treatment treat_directory(struct dir_struct *dir, >
[...]
Show 8 quoted lines
> > > + real_gitdir = real_pathdup(the_repository->gitdir, 0); > > This function is repeatedly called during the traversal. > > How expensive is it to keep calling real_pathdup() on the constant > the_repository->gitdir just in case it might be the same as our true > GIT_DIR?
I agree that treat_directory is called many times, but this real_pathdup() call is inside the "if (nested_repo)" block, so this new real_pathdup() invocation should occur very seldom. Or are you worried about cases where users have *very* large numbers of bare repositories nested under the working directory? Even in that case, which seems pathological to me, I'd suspect the is_nonbare_repository_dir() -> read_gitfile_gently()/is_git_directory() codepath (used to determine the value of nested_repo) would be much more expensive than this call to real_pathdup(), so would it be worth trying to optimize this real_pathdup() call away even in that rare case?