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.
This commit is contained in:
Wilco Dijkstra 2014-10-24 16:12:12 +00:00
parent 6e46de42fe
commit e80514b5a8
2 changed files with 6 additions and 4 deletions

View File

@ -1,3 +1,7 @@
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> 2014-10-24 Wilco Dijkstra <wdijkstr@arm.com>
* string/strcat.c (strcat): Improve performance by using strlen/strcpy. * string/strcat.c (strcat): Improve performance by using strlen/strcpy.

View File

@ -33,13 +33,11 @@ STRNCAT (char *s1, const char *s2, size_t n)
char *s = s1; char *s = s1;
/* Find the end of S1. */ /* Find the end of S1. */
do s1 += strlen (s1);
c = *s1++;
while (c != '\0');
/* Make S1 point before next character, so we can increment /* Make S1 point before next character, so we can increment
it while memory is read (wins on pipelined cpus). */ it while memory is read (wins on pipelined cpus). */
s1 -= 2; s1 -= 1;
if (n >= 4) if (n >= 4)
{ {