summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authordzwdz2022-03-27 21:48:03 +0200
committerdzwdz2022-03-27 21:48:03 +0200
commitead1f9bac4d7c806af6d52fec48c9287b1d5b3e2 (patch)
treefbc82af1f8e6b4413b8dd310325abb9d71a416f7 /src/shared
parentf1cefa851c3bc8aa6a8c2e6b86d23d87db342a2d (diff)
shared/memcpy: copy in 4byte blocks
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/mem.c16
1 files changed, 12 insertions, 4 deletions
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;
}