diff options
author | Wilco Dijkstra <wdijkstr@arm.com> | 2014-10-24 16:12:12 +0000 |
---|---|---|
committer | Wilco Dijkstra <wdijkstr@arm.com> | 2014-10-24 16:12:12 +0000 |
commit | e80514b5a87c86a92352ce526c4b9db85f2a242c (patch) | |
tree | eef102c72f8f43c86bbfc67b8343a6cf555bc47c | |
parent | 6e46de42fe1695818a410a7b86d26be8b1527524 (diff) | |
download | glibc-e80514b5a87c86a92352ce526c4b9db85f2a242c.zip glibc-e80514b5a87c86a92352ce526c4b9db85f2a242c.tar.gz glibc-e80514b5a87c86a92352ce526c4b9db85f2a242c.tar.bz2 |
This patch improves strncat performance by using strlen. Strlen has a fast C implementation, so
this
will improve performance even on targets which don't have an optimized strlen. It is about twice
as
fast as the original strncat in bench-strncat.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | string/strncat.c | 6 |
2 files changed, 6 insertions, 4 deletions
@@ -1,5 +1,9 @@ 2014-10-24 Wilco Dijkstra <wdijkstr@arm.com> + * string/strncat.c (strncat): Improve performance by using strlen. + +2014-10-24 Wilco Dijkstra <wdijkstr@arm.com> + * string/strcat.c (strcat): Improve performance by using strlen/strcpy. 2014-10-24 Wilco Dijkstra <wdijkstr@arm.com> diff --git a/string/strncat.c b/string/strncat.c index 7ac4456..6d29114 100644 --- a/string/strncat.c +++ b/string/strncat.c @@ -33,13 +33,11 @@ STRNCAT (char *s1, const char *s2, size_t n) char *s = s1; /* Find the end of S1. */ - do - c = *s1++; - while (c != '\0'); + s1 += strlen (s1); /* Make S1 point before next character, so we can increment it while memory is read (wins on pipelined cpus). */ - s1 -= 2; + s1 -= 1; if (n >= 4) { |