[PATCH] Use strlen when searching for a nul char

Wilco Dijkstra wdijkstr@arm.com
Wed Oct 7 14:50:00 GMT 2015


> pinskia@gmail.com wrote:
> > On Oct 7, 2015, at 7:30 AM, Wilco Dijkstra <wdijkstr@arm.com> wrote:
> >
> > Expand strchr (s, '\0') in C/C++ to use strlen. This is faster on most targets as strlen is
> a
> > simpler function. Passes GLIBC tests. I'm planning to do the same for strrchr, strchrnul and
> > rawmemchr in future patches as people frequently use all of these to find the end of a
> string.
> >
> > OK for commit?
> 
> Shouldn't this also be an optimization inside gcc if not already?

Absolutely, GCC is missing many of these simple optimizations.

Wilco




More information about the Libc-alpha mailing list