This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 1/*] Optimize memccpy.
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Roland McGrath <roland at hack dot frob dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Fri, 20 Sep 2013 09:35:42 +0200
- 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>
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