Subject: Re: [PATCH] match_pathname(): give fnmatch one char of prefix context

From: Junio C Hamano <[email-masked]>
Date: Sun, 26 Oct 2025 16:29:40 -0700

Jeff King <[email-masked]> writes:

> I also wonder how expensive that memcmp() is. ;) Obviously not very, but
> if the point is that we are trying to save fnmatch from looking at that
> one extra character, we already pinching pennies in a mostly
> un-measurable way.

I added the "limit to known bad case" in the illustration not for
performance but for correctness.  This was because just like we
weren't convinced that the "**/" may be the only case that breaks
the existing optimization, I was worried if stepping back by one
byte may somehow make a pattern that should not match mistakenly
match.

In any case, your numbers did make sense and tells us that optimized
strncmp() is much faster than comparing a byte at a time, which is
expected.

Thanks.