rawmemchr

Christopher Faylor cgf-use-the-mailinglist-please@cygwin.com
Wed May 21 03:22:00 GMT 2008


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



More information about the Cygwin-developers mailing list