mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nathan Moinvaziri <nathan@nathanm.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Andy Shevchenko <andy@kernel.org>
Subject: Re: [PATCH] lib/string.c: Improve strcasecmp speed by not lowering if chars match
Date: Tue, 25 Oct 2022 23:27:55 +0000	[thread overview]
Message-ID: <4eb86647-488e-4976-1580-d03d49a65f2c@nathanm.com> (raw)
In-Reply-To: <bad224c0-98a3-37db-99c3-b44687cc396e@wanadoo.fr>

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


  reply	other threads:[~2022-10-25 23:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-25  1:46 Nathan Moinvaziri
2022-10-25  8:00 ` Andy Shevchenko
2022-10-25  9:03   ` Andy Shevchenko
2022-10-25 17:53     ` Nathan Moinvaziri
2022-10-25 19:19       ` Andy Shevchenko
2022-10-27  3:29         ` Nathan Moinvaziri
2022-10-27  6:31           ` Andy Shevchenko
2022-10-25 19:32       ` Christophe JAILLET
2022-10-25 23:27         ` Nathan Moinvaziri [this message]
2022-10-25 19:55   ` Rasmus Villemoes
2022-10-25 22:37     ` Nathan Moinvaziri

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4eb86647-488e-4976-1580-d03d49a65f2c@nathanm.com \
    --to=nathan@nathanm.com \
    --cc=andy@kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®