Re: [PATCH 1/1] lib: use sunday algorithm to do strstr() and strnstr()

From: Andy Shevchenko
Date: Fri Jul 27 2018 - 06:39:25 EST

On Fri, Jul 27, 2018 at 8:48 AM, Zhaoxiu Zeng <zengzhaoxiu@xxxxxxx> wrote:
> å 2018/7/27 1:17, Zhaoxiu Zeng åé:
>> å 2018/7/23 2:37, Greg Kroah-Hartman åé:
>>> On Mon, Jul 23, 2018 at 01:37:15AM +0800, Zhaoxiu Zeng wrote:

>>>> The Sunday algorithm is a variation of Boyer-Moore algorithm, it is easy and fast.
>>>> For the Sunday algorithm, to see
>>> So you say, but what does this really buy us? Why make this change?
>>> How was it tested? What is the downside of not taking this?

>> I use the following program to test on fc28.
>> Compile with O2, the new version is almost 2X faster than the original.

>> The code size of the original is 0x80, the newer is 0xB0.

So, output of bloat-o-meter would be good to have in commit message.

>> The test result:

Compact performance statistics as well.

>> Thanks!

> The original strnstr might has a bug too!
> For example, assume s1 is "123\0abc...." and s2 is "abc\0",
> call strnstr(s1, s2, 7) will return &s1[4], but the correct result is NULL.

If there is a bug, send another patch to fix the bug first.

With Best Regards,
Andy Shevchenko