From ead1f9bac4d7c806af6d52fec48c9287b1d5b3e2 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 27 Mar 2022 21:48:03 +0200 Subject: shared/memcpy: copy in 4byte blocks --- src/shared/mem.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/shared') diff --git a/src/shared/mem.c b/src/shared/mem.c index eb34445..35b2f14 100644 --- a/src/shared/mem.c +++ b/src/shared/mem.c @@ -13,10 +13,18 @@ int memcmp(const void *s1, const void *s2, size_t n) { } void *memcpy(void *dest, const void *src, size_t n) { - char *d = dest; - const char *s = src; - for (size_t i = 0; i < n; i++) - d[i] = s[i]; + const uint32_t *s32 = src; + uint32_t *d32 = dest; + while (n >= 4) { + *d32++ = *s32++; + n -= 4; + } + + const char *s8 = (void*)s32; + char *d8 = (void*)d32; + while (n-- != 0) + *d8++ = *s8++; + return dest; } -- cgit v1.2.3