Fastest String Search Algorithm.

Dan Raymond draymond@foxvalley.net
Fri Jun 11 20:00:30 GMT 2021


> So, in this case, my algorithm is of no use because it better than strstr()
> in average cases but not in worst cases.
>
> Average case means real world scenarios. Worst case means hand crafted
> worst case inputs.

Real world scenarios are precisely the ones that are sensitive to 
worst-case performance.  In the real world you can't predict inputs and 
there are consequences to unexpected performance problems.  Denial of 
service attacks are just one example.  By the way your previous argument 
that antivirus software uses strstr() to search for virus signatures is 
false.  A virus signature is not a NUL-terminated string.



More information about the Libc-alpha mailing list