Git development
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Tamir Duberstein <tamird@gmail.com>
Cc: git@vger.kernel.org, "René Scharfe" <l.s.r@web.de>,
	"Patrick Steinhardt" <ps@pks.im>,
	"Junio C Hamano" <gitster@pobox.com>
Subject: Re: [PATCH v2] ls-files: filter pathspec before lstat
Date: Tue, 9 Jun 2026 06:41:19 -0400	[thread overview]
Message-ID: <20260609104119.GA1509396@coredump.intra.peff.net> (raw)
In-Reply-To: <20260608-ls-files-pathspec-lstat-v2-1-fb734b28422e@gmail.com>

On Mon, Jun 08, 2026 at 07:37:15PM -0700, Tamir Duberstein wrote:

> +		/*
> +		 * match_pathspec() is linear in pathspec.nr, so prefilter only
> +		 * the single-pathspec case. Only entries shown by show_ce()
> +		 * satisfy --error-unmatch.
> +		 */
> +		if (pathspec.nr == 1 &&
> +		    !match_pathspec(repo->index, &pathspec, fullname.buf,
> +				    fullname.len, max_prefix_len, NULL,
> +				    S_ISDIR(ce->ce_mode) ||
> +				    S_ISGITLINK(ce->ce_mode)))
> +			continue;

This feels...kind of arbitrary, no? Surely it's also faster with
pathspec.nr == 2, and so on up to some nr closer to the size of the
total index. It feels weird to be making an arbitrary cutoff based on
pathspec performance in calling code like this.

It is not wrong, per se, as you are optimizing your case without trying
to hurt any others. But what do we do when somebody profiles it and
comes along trying to bump the number to 2, or 10?

I dunno.

-Peff

  parent reply	other threads:[~2026-06-09 10:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-09  2:37 [PATCH v2] ls-files: filter pathspec before lstat Tamir Duberstein
2026-06-09  3:26 ` Junio C Hamano
2026-06-09  3:38   ` Tamir Duberstein
2026-06-09  3:42   ` Junio C Hamano
2026-06-09  3:48     ` Tamir Duberstein
2026-06-09 10:41 ` Jeff King [this message]
2026-06-09 23:15   ` Tamir Duberstein
2026-06-11  8:41     ` Jeff King
2026-06-11 15:17       ` Tamir Duberstein
2026-06-11 17:38       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260609104119.GA1509396@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=l.s.r@web.de \
    --cc=ps@pks.im \
    --cc=tamird@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox