mirror of git://sourceware.org/git/glibc.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.
This commit is contained in:
parent
81a1443941
commit
4d8015639a
|
@ -1,5 +1,7 @@
|
||||||
2019-02-27 Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
2019-02-27 Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
|
||||||
|
* wcsmbs/wcscpy.c (__wcpcpy): Rewrite using wcslen and wmemcpy.
|
||||||
|
|
||||||
* include/wchar.h (__wcscpy): New prototype.
|
* include/wchar.h (__wcscpy): New prototype.
|
||||||
* sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-ppc32.c
|
* sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-ppc32.c
|
||||||
(__wcscpy): Route internal symbol to generic implementation.
|
(__wcscpy): Route internal symbol to generic implementation.
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
License along with the GNU C Library; if not, see
|
License along with the GNU C Library; if not, see
|
||||||
<http://www.gnu.org/licenses/>. */
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,35 +27,7 @@
|
||||||
wchar_t *
|
wchar_t *
|
||||||
__wcscpy (wchar_t *dest, const wchar_t *src)
|
__wcscpy (wchar_t *dest, const wchar_t *src)
|
||||||
{
|
{
|
||||||
wint_t c;
|
return __wmemcpy (dest, src, __wcslen (src) + 1);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
#ifndef WCSCPY
|
#ifndef WCSCPY
|
||||||
weak_alias (__wcscpy, wcscpy)
|
weak_alias (__wcscpy, wcscpy)
|
||||||
|
|
Loading…
Reference in New Issue