This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 07/11] Improve generic strnlen
On 12/19/2016 06:59 AM, Adhemerval Zanella wrote:
> As for strchr, since you already optimizing memchr why not base
> strnlen on memchr instead:
>
> --
> size_t
> __strnlen (const char *str, size_t maxlen)
> {
> const char *char_str = memchr (str, 0, maxlen);
> return char_str ? char_str - s : maxlen;
> }
> --
Yes, I think this is the right thing here. Unlike strchr, strnlen is a lesser
used function.
r~