This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Improve performance of strcpy
- From: "Wilco Dijkstra" <wdijkstr at arm dot com>
- To: <libc-alpha at sourceware dot org>
- Date: Tue, 23 Sep 2014 18:54:37 +0100
- Subject: [PATCH] Improve performance of strcpy
- Authentication-results: sourceware.org; auth=none
Hi,
Similar to previous patches, this patch improves strcpy performance by using strlen+memcpy. This is
significantly faster than a simple byte-loop, on bench-strcpy speedup is > 2x.
ChangeLog:
2014-09-23 Wilco Dijkstra <wdijkstr@arm.com>
* string/strcpy.c (strcpy):
Improve performance by using strlen and memcpy.
---
string/strcpy.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/string/strcpy.c b/string/strcpy.c
index caa234a..91f9cc6 100644
--- a/string/strcpy.c
+++ b/string/strcpy.c
@@ -24,17 +24,6 @@
char *
strcpy (char *dest, const char *src)
{
- char c;
- char *s = (char *) src;
- const ptrdiff_t off = dest - s - 1;
-
- do
- {
- c = *s++;
- s[off] = c;
- }
- while (c != '\0');
-
- return dest;
+ return memcpy (dest, src, strlen (src) + 1));
}
libc_hidden_builtin_def (strcpy)
--
1.7.9.5