This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 02/11] Improve generic strchr


On 12/19/2016 06:38 AM, Adhemerval Zanella wrote:
> Since you are changing strchrnul, why not just simplify strchr to just:
> 
> --
> /* Find the first occurrence of C in S.  */
> char *
> STRCHR (const char *s, int c_in)
> {
>   char *r = __strchrnul (s, c_in);
>   return *(unsigned char *) r == (unsigned char) c_in ? r : NULL;
> }
> --
> 
> ?
> 
> It will incur in a function call, but as least it has two main advantages:
> 
>  - less icache pressure due potentially less code.
>  - an architecture that uses default strchr and strchrnull will require just
>    to provide an optimized strchrnul to get a boot on both symbols.

Surely strchr is used vastly more often than strchrnul.  I'd prefer the more
common symbol to avoid another function call.


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]