OSDN Git Service
(root)
/
android-x86
/
bionic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b9e49ad
)
libc: memmove(): non-overlapping block optim.
author
David 'Digit' Turner
<digit@google.com>
Sun, 26 Sep 2010 20:40:02 +0000
(22:40 +0200)
committer
David 'Digit' Turner
<digit@google.com>
Mon, 27 Sep 2010 15:34:41 +0000
(17:34 +0200)
Change-Id: I5652f4f97ca59d95176443fc27c737ef76258183
libc/string/memmove.c
patch
|
blob
|
history
diff --git
a/libc/string/memmove.c
b/libc/string/memmove.c
index
fcaf4ee
..
948a766
100644
(file)
--- a/
libc/string/memmove.c
+++ b/
libc/string/memmove.c
@@
-31,7
+31,11
@@
void *memmove(void *dst, const void *src, size_t n)
{
const char *p = src;
char *q = dst;
- if (__builtin_expect(q < p, 1)) {
+
+ /* we can use highgly-optimized memcpy() if the destination
+ * is before the source, or if the two blocks are non-overlapping
+ */
+ if (__builtin_expect((q < p || (q-p) <= (ptrdiff_t)n), 1)) {
return memcpy(dst, src, n);
} else {
#define PRELOAD_DISTANCE 64