libc: optimize memmove() with memcpy() if possible.
Change-Id: I90e578fdc82e427caee8fa4157ce3f8c6c99926d
This commit is contained in:
parent
af00228b70
commit
5b81b91817
@ -31,7 +31,10 @@ void *memmove(void *dst, const void *src, size_t n)
|
|||||||
{
|
{
|
||||||
const char *p = src;
|
const char *p = src;
|
||||||
char *q = dst;
|
char *q = dst;
|
||||||
if (__builtin_expect(q < p, 1)) {
|
/* We can use the optimized memcpy if the destination is below the
|
||||||
|
* source (i.e. q < p), or if it is completely over it (i.e. q >= p+n).
|
||||||
|
*/
|
||||||
|
if (__builtin_expect((q < p) || ((size_t)(q - p) >= n), 1)) {
|
||||||
return memcpy(dst, src, n);
|
return memcpy(dst, src, n);
|
||||||
} else {
|
} else {
|
||||||
#define PRELOAD_DISTANCE 64
|
#define PRELOAD_DISTANCE 64
|
||||||
|
Loading…
x
Reference in New Issue
Block a user