This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 1/4] Improve generic strcspn performance
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>, "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>
- Cc: nd <nd at arm dot com>
- Date: Thu, 31 Mar 2016 15:28:09 -0300
- Subject: Re: [PATCH 1/4] Improve generic strcspn performance
- Authentication-results: sourceware.org; auth=none
- References: <1459432863-20749-1-git-send-email-adhemerval dot zanella at linaro dot org> <1459432863-20749-2-git-send-email-adhemerval dot zanella at linaro dot org> <AM3PR08MB0088F4DF6B765B616B44E0F183990 at AM3PR08MB0088 dot eurprd08 dot prod dot outlook dot com>
On 31-03-2016 11:49, Wilco Dijkstra wrote:
> Adhemerval Zanella wrote:
>
> size_t
> -STRCSPN (const char *s, const char *reject)
> +STRCSPN (const char *str, const char *reject)
> {
> - size_t count = 0;
> + if (reject[0] == '\0' || reject[1] == '\0')
> + return __strchrnul (str, reject [0]) - str;
>
> I agree using __strchrnul is fine if reject[0] == '\0' as that should be very rare.
> However it needs __glibc_unlikely again to avoid slowing down the common case.
> It's odd that GCC doesn't predict that the first character(s) of a string are non-zero...
>
> Other than that, it looks good.
>
> Wilco
>
Right, I will change that.