Skip to content
Snippets Groups Projects
Commit cb0eae8c authored by Simon Glass's avatar Simon Glass Committed by Tom Rini
Browse files

string: Use memcpy() within memmove() when we can


A common use of memmove() can be handled by memcpy(). Also memcpy()
includes an optimisation for large sizes: it copies a word at a time. So
we can get a speed-up by calling memcpy() to handle our move in this case.

Update memmove() to call memcpy() if the destination is before the source.

Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
Reviewed-by: default avatarTom Rini <trini@konsulko.com>
parent 20b429b0
No related branches found
No related tags found
No related merge requests found
...@@ -511,16 +511,9 @@ void * memmove(void * dest,const void *src,size_t count) ...@@ -511,16 +511,9 @@ void * memmove(void * dest,const void *src,size_t count)
{ {
char *tmp, *s; char *tmp, *s;
if (src == dest)
return dest;
if (dest <= src) { if (dest <= src) {
tmp = (char *) dest; memcpy(dest, src, count);
s = (char *) src; } else {
while (count--)
*tmp++ = *s++;
}
else {
tmp = (char *) dest + count; tmp = (char *) dest + count;
s = (char *) src + count; s = (char *) src + count;
while (count--) while (count--)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment