diff mbox series

[4/7] wcsmbs: optimize wcscpy

Message ID 20190206145850.22003-4-adhemerval.zanella@linaro.org
State New
Headers show
Series [1/7] wcsmbs: optimize wcpcpy | expand

Commit Message

Adhemerval Zanella Feb. 6, 2019, 2:58 p.m. UTC
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.
---
 wcsmbs/wcscpy.c | 31 +------------------------------
 1 file changed, 1 insertion(+), 30 deletions(-)

-- 
2.17.1

Comments

Florian Weimer Feb. 11, 2019, 8:33 a.m. UTC | #1
* Adhemerval Zanella:

> 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.


Looks okay.  Thanks.

Florian
diff mbox series

Patch

diff --git a/wcsmbs/wcscpy.c b/wcsmbs/wcscpy.c
index 636bf6bd01..0ed4d4b3d7 100644
--- a/wcsmbs/wcscpy.c
+++ b/wcsmbs/wcscpy.c
@@ -19,7 +19,6 @@ 
 #include <stddef.h>
 #include <wchar.h>
 
-
 #ifdef WCSCPY
 # define __wcscpy WCSCPY
 #endif
@@ -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)