From: Adhemerval Zanella Date: Tue, 5 Feb 2019 20:32:03 +0000 (-0200) Subject: wcsmbs: optimize wcscpy X-Git-Tag: upstream/2.30~325 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4d8015639a750aacd899e293bceeabb15bde9803;p=platform%2Fupstream%2Fglibc.git 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. --- diff --git a/ChangeLog b/ChangeLog index b963736..2406275 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2019-02-27 Adhemerval Zanella + * 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. diff --git a/wcsmbs/wcscpy.c b/wcsmbs/wcscpy.c index 636bf6b..6fb2969 100644 --- a/wcsmbs/wcscpy.c +++ b/wcsmbs/wcscpy.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include @@ -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)