[PATCH] Add strchrnul
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2877 bytes
Desc: not available
More information about the Newlib