mailing list of musl libc
 help / color / mirror / code / Atom feed
* wmemcpy: call memcpy
@ 2017-06-25 17:44 Andrew Salmon
  0 siblings, 0 replies; only message in thread
From: Andrew Salmon @ 2017-06-25 17:44 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 557 bytes --]

Currently, wmemcpy is implemented as a loop, which the compiler
aggressively optimizes.  From a binary perspective it's probably cleaner to
implement it as a call to memcpy.

diff --git a/src/string/wmemcpy.c b/src/string/wmemcpy.c
index 52e6e6e..272f37a 100644
--- a/src/string/wmemcpy.c
+++ b/src/string/wmemcpy.c
@@ -1,8 +1,7 @@
+#include <string.h>
 #include <wchar.h>

 wchar_t *wmemcpy(wchar_t *restrict d, const wchar_t *restrict s, size_t n)
 {
- wchar_t *a = d;
- while (n--) *d++ = *s++;
- return a;
+ return memcpy(d, s, n * sizeof(wchar_t));
 }

[-- Attachment #2: Type: text/html, Size: 1041 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-06-25 17:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-25 17:44 wmemcpy: call memcpy Andrew Salmon

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).