lkml.org 
[lkml]   [2022]   [Oct]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] lib/string.c: Improve strcasecmp speed by not lowering if chars match
Date
On 10/25/2022 12:32 PM, Christophe JAILLET wrote:
> Hi,
> the algorithm on github is not the same as the one posted here.
>
> IIUC, the one on github is wrong. If you compare 2 strings that are
> the same, they will have the same length, and "if (c1 == c2)
> continue;" will go one past the end of the strings. And the result
> will be <0 or 0 or >0 depending the the char *after* the trailing \0.
>
> On the other side, the results of the benchmark on github are likely
> not accurate with the algorithm posted here, because there is one more
> test in each loop ("while (c1 != 0)") as long as the 2 strings are the
> same.
> On github this test is skipped because you will go through the "continue"
>
> CJ

Hi CJ,

Thanks for catching that, I had changed it at the last second. I have
updated the code and the benchmarks to what I initially proposed in the
patch. Results are about +/-1% from previously.

Nathan

\
 
 \ /
  Last update: 2022-10-26 01:28    [W:0.197 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site