[PATCH] Add strchrnul
Yaakov (Cygwin/X)
yselkowitz@users.sourceforge.net
Mon Mar 28 14:53:00 GMT 2011
On Mon, 2011-03-28 at 10:10 +0200, Corinna Vinschen wrote:
> Isn't this implementation a bit simple? It's as fast as the underlying
> strchr function in case of a hit, but it suffers quite a performance hit
> in case of a miss, because the string has to be scanned twice.
>
> So I'm wondering, shouldn't we better adapt the strchr implementation
> and just return a pointer to s where strchr returns NULL?
There's always a tradeoff, simplicity vs. code duplication. I presume
you mean something like the attached. I'm just not sure about the !
PREFER_SIZE_OVER_SPEED block of the code.
Yaakov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: strchrnul.c
Type: text/x-csrc
Size: 2877 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20110328/3aecb4e0/attachment.bin>
More information about the Newlib
mailing list