提交 cb0eae8c 编写于 作者: S Simon Glass 提交者: Tom Rini

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: NSimon Glass <sjg@chromium.org>
Reviewed-by: NTom Rini <trini@konsulko.com>
上级 20b429b0
......@@ -511,16 +511,9 @@ void * memmove(void * dest,const void *src,size_t count)
{
char *tmp, *s;
if (src == dest)
return dest;
if (dest <= src) {
tmp = (char *) dest;
s = (char *) src;
while (count--)
*tmp++ = *s++;
}
else {
memcpy(dest, src, count);
} else {
tmp = (char *) dest + count;
s = (char *) src + count;
while (count--)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册