Re: [PATCH] match_pathname(): give fnmatch one char of prefix context
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 26, 2025, 23:29 UTC
- Message-ID
- <xmqq7bwhmecb.fsf@gitster.g>
- In-Reply-To
- <20251026152614.GB2095501@coredump.intra.peff.net>
Jeff King <peff@peff.net> 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.