diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2019-02-05 17:35:12 -0200 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2019-02-27 10:00:37 -0300 |
commit | 81a14439417552324ec6ca71f65ddf8e7cdd51c7 (patch) | |
tree | 3300f5fec6acc1ef4c95c333bf165ebb51248f68 /wcsmbs | |
parent | 39ef07441910c2d2f8c02579e808862194b9a23b (diff) | |
download | glibc-81a14439417552324ec6ca71f65ddf8e7cdd51c7.tar.gz glibc-81a14439417552324ec6ca71f65ddf8e7cdd51c7.tar.xz glibc-81a14439417552324ec6ca71f65ddf8e7cdd51c7.zip |
wcsmbs: optimize wcscat
This patch rewrites wcscat using wcslen and wcscpy. This is similar to the optimization done on strcat by 6e46de42fe. The strcpy changes are mainly to add the internal alias to avoid PLT calls. Checked on x86_64-linux-gnu and a build against the affected architectures. * include/wchar.h (__wcscpy): New prototype. * sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-ppc32.c (__wcscpy): Route internal symbol to generic implementation. * sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy.c (wcscpy): Add internal __wcscpy alias. * sysdeps/powerpc/powerpc64/multiarch/wcscpy.c (wcscpy): Likewise. * sysdeps/s390/wcscpy.c (wcscpy): Likewise. * sysdeps/x86_64/multiarch/wcscpy.c (wcscpy): Likewise. * wcsmbs/wcscpy.c (wcscpy): Add * sysdeps/x86_64/multiarch/wcscpy-c.c (WCSCPY): Adjust macro to use generic implementation. * wcsmbs/wcscat.c (wcscat): Rewrite using wcslen and wcscpy.
Diffstat (limited to 'wcsmbs')
-rw-r--r-- | wcsmbs/wcscat.c | 21 | ||||
-rw-r--r-- | wcsmbs/wcscpy.c | 10 |
2 files changed, 8 insertions, 23 deletions
diff --git a/wcsmbs/wcscat.c b/wcsmbs/wcscat.c index 6a25b20e31..1a9d667fda 100644 --- a/wcsmbs/wcscat.c +++ b/wcsmbs/wcscat.c @@ -26,26 +26,7 @@ wchar_t * __wcscat (wchar_t *dest, const wchar_t *src) { - wchar_t *s1 = dest; - const wchar_t *s2 = src; - wchar_t c; - - /* Find the end of the string. */ - do - c = *s1++; - while (c != L'\0'); - - /* Make S1 point before the next character, so we can increment - it while memory is read (wins on pipelined cpus). */ - s1 -= 2; - - do - { - c = *s2++; - *++s1 = c; - } - while (c != L'\0'); - + __wcscpy (dest + __wcslen (dest), src); return dest; } #ifndef WCSCAT diff --git a/wcsmbs/wcscpy.c b/wcsmbs/wcscpy.c index 7a34c77a9e..636bf6bd01 100644 --- a/wcsmbs/wcscpy.c +++ b/wcsmbs/wcscpy.c @@ -20,13 +20,13 @@ #include <wchar.h> -#ifndef WCSCPY -# define WCSCPY wcscpy +#ifdef WCSCPY +# define __wcscpy WCSCPY #endif /* Copy SRC to DEST. */ wchar_t * -WCSCPY (wchar_t *dest, const wchar_t *src) +__wcscpy (wchar_t *dest, const wchar_t *src) { wint_t c; wchar_t *wcp; @@ -58,3 +58,7 @@ WCSCPY (wchar_t *dest, const wchar_t *src) return dest; } +#ifndef WCSCPY +weak_alias (__wcscpy, wcscpy) +libc_hidden_def (__wcscpy) +#endif |