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]

[PATCH 4/*] Generic string memchr and strnlen


Getting back to this, if you don't have an optimized strnlen then
it is always better to try to use memchr (there are 14 optimized
implementations of memchr but only 6 for strnlen).

So I'd suggest changing strnlen in an independent patch as:

__strnlen (const char *str, size_t n)
{
  char *ret = __memchr (str, 0, n); 
  return ret ? ret - str : n;
}

It also looks worthwhile to express strlen and rawmemchr as memchr
so that you only need one highly optimized function rather than many.
Deferring to more widely implemented optimized assembler functions
should result in better performance than trying to optimize these
functions in C.

Wilco




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