summary refs log tree commit diff
path: root/wcsmbs
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-02-05 18:32:03 -0200
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-02-27 10:00:42 -0300
commit4d8015639a750aacd899e293bceeabb15bde9803 (patch)
tree59d4970fef40ebb328bad595252c7227055e9bbf /wcsmbs
parent81a14439417552324ec6ca71f65ddf8e7cdd51c7 (diff)
downloadglibc-4d8015639a750aacd899e293bceeabb15bde9803.tar.gz
glibc-4d8015639a750aacd899e293bceeabb15bde9803.tar.xz
glibc-4d8015639a750aacd899e293bceeabb15bde9803.zip
wcsmbs: optimize wcscpy
This patch rewrites wcscpy using wcslen and wmemcpy.  This is similar
to the optimization done on strcpy by b863d2bc4d.

Checked on x86_64-linux-gnu.

	* wcsmbs/wcscpy.c (__wcpcpy): Rewrite using wcslen and wmemcpy.
Diffstat (limited to 'wcsmbs')
-rw-r--r--wcsmbs/wcscpy.c31
1 files changed, 1 insertions, 30 deletions
diff --git a/wcsmbs/wcscpy.c b/wcsmbs/wcscpy.c
index 636bf6bd01..6fb2969513 100644
--- a/wcsmbs/wcscpy.c
+++ b/wcsmbs/wcscpy.c
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <stddef.h>
 #include <wchar.h>
 
 
@@ -28,35 +27,7 @@
 wchar_t *
 __wcscpy (wchar_t *dest, const wchar_t *src)
 {
-  wint_t c;
-  wchar_t *wcp;
-
-  if (__alignof__ (wchar_t) >= sizeof (wchar_t))
-    {
-      const ptrdiff_t off = dest - src - 1;
-
-      wcp = (wchar_t *) src;
-
-      do
-	{
-	  c = *wcp++;
-	  wcp[off] = c;
-	}
-      while (c != L'\0');
-    }
-  else
-    {
-      wcp = dest;
-
-      do
-	{
-	  c = *src++;
-	  *wcp++ = c;
-	}
-      while (c != L'\0');
-    }
-
-  return dest;
+  return __wmemcpy (dest, src, __wcslen (src) + 1);
 }
 #ifndef WCSCPY
 weak_alias (__wcscpy, wcscpy)