This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 1/*] Optimize memccpy.
- From: Liubov Dmitrieva <liubov dot dmitrieva at gmail dot com>
- To: Ondřej Bílka <neleai at seznam dot cz>
- Cc: Roland McGrath <roland at hack dot frob dot com>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Fri, 27 Sep 2013 12:04:32 +0400
- Subject: Re: [PATCH 1/*] Optimize memccpy.
- Authentication-results: sourceware.org; auth=none
- References: <20130904000359 dot GA11634 at domone dot kolej dot mff dot cuni dot cz> <20130918220505 dot 29E702C09F at topped-with-meat dot com> <20130920073542 dot GC15916 at domone>
Maybe better?
* string/memccpy.c: Use faster implementation.
I believe it should be faster everywhere but to be accurate you should
probably check performance on x86_32, powerpc, ...
--
Liubov
On Fri, Sep 20, 2013 at 11:35 AM, OndÅej BÃlka <neleai@seznam.cz> wrote:
> On Wed, Sep 18, 2013 at 03:05:05PM -0700, Roland McGrath wrote:
>> name space violation
>
> ok, here is v2.
>
> * string/memccpy.c: Use implementation from
> benchtests/bench-memccpy.c
>
> ---
> string/memccpy.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/string/memccpy.c b/string/memccpy.c
> index 2a33032..e1fca70 100644
> --- a/string/memccpy.c
> +++ b/string/memccpy.c
> @@ -30,15 +30,12 @@ __memccpy (dest, src, c, n)
> int c;
> size_t n;
> {
> - const char *s = src;
> - char *d = dest;
> - const char x = c;
> - size_t i = n;
> + void *p = __memchr (src, c, n);
>
> - while (i-- > 0)
> - if ((*d++ = *s++) == x)
> - return d;
> + if (p != NULL)
> + return __mempcpy (dest, src, p - src + 1);
>
> + memcpy (dest, src, n);
> return NULL;
> }
>
> --
> 1.8.3.2
>