This is the mail archive of the
cygwin-developers
mailing list for the Cygwin project.
Re: rawmemchr
- From: Christopher Faylor <cgf-use-the-mailinglist-please at cygwin dot com>
- To: cygwin-developers at cygwin dot com
- Date: Tue, 20 May 2008 23:22:28 -0400
- Subject: Re: rawmemchr
- References: <483386B5.20507@byu.net>
- Reply-to: cygwin-developers at cygwin dot com
On Tue, May 20, 2008 at 08:19:33PM -0600, Eric Blake wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I noticed that the cygwin source code frequently uses strchr(p,0) to find
> the trailing NUL of a string. glibc documents that they special case this
> condition to be noticeably faster than normal strchr, and a couple
> instructions faster than the corresponding strlen(p)+p; however, the
> current newlib implementation lacks this special case, and is somewhat
> inefficient when compared to glibc's extension of rawmemchr(p,0). Put
> another way, the current newlib implementation of strchr performs two
> checks for a NUL byte instead of one, making strchr almost twice as slow
> as strlen at finding the ending NUL.
Unless there's something I'm missing, cygwin should be using the assembly
language routines in string.h.
cgf