mirror of
git://sourceware.org/git/glibc.git
synced 2025-01-18 12:16:13 +08:00
Improve memccpy performance by using memchr/memcpy/mempcpy rather than
a byte loop. Overall performance on bench-memccpy is > 2x faster when using the C implementation of memchr and an optimized memcpy.
This commit is contained in:
parent
f6482cf29d
commit
f29ac72eff
@ -1,3 +1,8 @@
|
|||||||
|
2015-08-05 Wilco Dijkstra <wdijkstr@arm.com>
|
||||||
|
|
||||||
|
* string/memccpy.c (memccpy):
|
||||||
|
Improve performance by using memchr/memcpy/__mempcpy.
|
||||||
|
|
||||||
2015-08-05 Wilco Dijkstra <wdijkstr@arm.com>
|
2015-08-05 Wilco Dijkstra <wdijkstr@arm.com>
|
||||||
|
|
||||||
* string/strncpy.c (strncpy):
|
* string/strncpy.c (strncpy):
|
||||||
|
@ -26,15 +26,12 @@
|
|||||||
void *
|
void *
|
||||||
__memccpy (void *dest, const void *src, int c, size_t n)
|
__memccpy (void *dest, const void *src, int c, size_t n)
|
||||||
{
|
{
|
||||||
const char *s = src;
|
void *p = memchr (src, c, n);
|
||||||
char *d = dest;
|
|
||||||
const char x = c;
|
|
||||||
size_t i = n;
|
|
||||||
|
|
||||||
while (i-- > 0)
|
if (p != NULL)
|
||||||
if ((*d++ = *s++) == x)
|
return __mempcpy (dest, src, p - src + 1);
|
||||||
return d;
|
|
||||||
|
|
||||||
|
memcpy (dest, src, n);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user