From: Tamir Duberstein Date: Tue, 09 Jun 2026 23:15:41 GMT Subject: Re: [PATCH v2] ls-files: filter pathspec before lstat Message-ID: In-Reply-To: <20260609104119.GA1509396@coredump.intra.peff.net> On Tue, Jun 9, 2026 at 3:41 AM Jeff King wrote: > > 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. Yeah, absolutely it's arbitrary. The simplest answer is that others are welcome to bump this, provided they make the case for it.