From 5b19e9239ae25b9589e5ec1b827a1288271f05e7 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 13 Sep 2021 17:23:24 +0200 Subject: [PATCH] LibC: Upgrade memmove() to memcpy() when possible We were missing out on opportunities to use memcpy() instead of memmove() when the source and destination don't overlap. --- Userland/Libraries/LibC/string.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibC/string.cpp b/Userland/Libraries/LibC/string.cpp index b6b672e86f..20874fba7e 100644 --- a/Userland/Libraries/LibC/string.cpp +++ b/Userland/Libraries/LibC/string.cpp @@ -155,7 +155,7 @@ void* memset(void* dest_ptr, int c, size_t n) void* memmove(void* dest, const void* src, size_t n) { - if (dest < src) + if (((FlatPtr)dest - (FlatPtr)src) >= n) return memcpy(dest, src, n); u8* pd = (u8*)dest;