From: Andrew Salmon <andrew.salmon@yale.edu>
To: musl@lists.openwall.com
Subject: wmemcpy: call memcpy
Date: Sun, 25 Jun 2017 13:44:10 -0400 [thread overview]
Message-ID: <CABXCG3=+JAkJHvNamybrPREwHfpzM2QvLuvOm-dahmzsbEUd8A@mail.gmail.com> (raw)
[-- 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 --]
reply other threads:[~2017-06-25 17:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CABXCG3=+JAkJHvNamybrPREwHfpzM2QvLuvOm-dahmzsbEUd8A@mail.gmail.com' \
--to=andrew.salmon@yale.edu \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).