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 1/*] Optimize memccpy.


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
>


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