]> sourceware.org Git - glibc.git/commitdiff
wcsmbs: optimize wcscpy
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 5 Feb 2019 20:32:03 +0000 (18:32 -0200)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 27 Feb 2019 13:00:42 +0000 (10:00 -0300)
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.

ChangeLog
wcsmbs/wcscpy.c

index b9637367dd8e71a9945fbf12637f9fdf7a0e5745..24062754616503c58a58275cb8a41389925f83f4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2019-02-27  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
+       * wcsmbs/wcscpy.c (__wcpcpy): Rewrite using wcslen and wmemcpy.
+
        * include/wchar.h (__wcscpy): New prototype.
        * sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-ppc32.c
        (__wcscpy): Route internal symbol to generic implementation.
index 636bf6bd01142f0cfec5e4d77df23171b2086fcf..6fb2969513060d040d60e9c4d741f5848805f3c4 100644 (file)
@@ -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>
 
 
 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)
This page took 0.0705 seconds and 5 git commands to generate.