public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
To: Alejandro Colomar <alx.manpages@gmail.com>,
	"linux-man@vger.kernel.org" <linux-man@vger.kernel.org>
Cc: Alejandro Colomar <alx@kernel.org>,
	"libc-alpha@sourceware.org" <libc-alpha@sourceware.org>
Subject: Re: [PATCH] memchr.3: Deprecate rawmemchr(3)
Date: Fri, 6 Jan 2023 12:57:03 +0000	[thread overview]
Message-ID: <PAWPR08MB898270B26F1A5776B87DE3F883FB9@PAWPR08MB8982.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <20230105190246.17819-1-alx@kernel.org>

Hi Alex,

> It is not optimized, and it calls either strlen(3) or memchr(3), so the
> caller can do it directly, and it will be better.
>
> Suggested-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
> Signed-off-by: Alejandro Colomar <alx@kernel.org>

This looks good to me. Btw in the codesearch there are about 800
uses, the majority looks like prototypes etc, so there are few actual
uses. Interestingly GLIBC still contains this:

#ifdef _LIBC
      p = __rawmemchr (p, '\0');
#else
      p = strchr (p, '\0');
#endif

The strchr (p, 0) is optimized by compilers into strlen (since that's
obviously the right optimization) so adding rawmemchr was not
only wasted effort, but it made things slower as well. So we should
remove these uses from GLIBC.

Cheers,
Wilco

      reply	other threads:[~2023-01-06 12:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-05 19:02 Alejandro Colomar
2023-01-06 12:57 ` Wilco Dijkstra [this message]

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=PAWPR08MB898270B26F1A5776B87DE3F883FB9@PAWPR08MB8982.eurprd08.prod.outlook.com \
    --to=wilco.dijkstra@arm.com \
    --cc=alx.manpages@gmail.com \
    --cc=alx@kernel.org \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-man@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).