Fastest String Search Algorithm.

Phil Blundell pb@pbcl.net
Wed Jun 9 07:38:52 GMT 2021


On Wed, Jun 09, 2021 at 11:48:11AM +0530, Amit Choudhary via Libc-alpha wrote:
> If my algorithm is beating strstr() for long search patterns then I think
> that my algorithm should be included in glibc for long search patterns.

I'm not sure we have enough data yet to make a rational decision on this
kind of thing.  To evaluate a new algorithm properly we'd need to
understand its behaviour on a wide range of input data, together with
the frequency with which each kind of input is likely to occur.  It
would obviously be counterproductive to replace the existing algorithm
with one that performs better for rarely-encountered input but is worse
for frequently-encountered input.

When you say "included [...] for long search patterns", what exactly are
you proposing?  Are you suggesting that strstr() should have some kind
of frontend wrapper which computes the length of the pattern and then
decides which algorithm to use?  If so then we would need to include the
cost of that length computation in the performance calculations.

Thanks

Phil


More information about the Libc-alpha mailing list