Forráskód Böngészése

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.
Andreas Kling 3 éve
szülő
commit
5b19e9239a
1 módosított fájl, 1 hozzáadás és 1 törlés
  1. 1 1
      Userland/Libraries/LibC/string.cpp

+ 1 - 1
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;