[PATCH 1/*] Optimize memccpy.
Ondřej Bílka
neleai@seznam.cz
Fri Sep 20 18:36:00 GMT 2013
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
More information about the Libc-alpha
mailing list