mirror of
https://sourceware.org/git/glibc.git
synced 2025-06-13 19:21:36 +03:00
This patch improves strcat performance by using strlen and strcpy. Strlen has a fast C
implementation, so this improves performance even on targets which don't have an optimized strlen and strcpy - it is 25% faster in bench-strcat. On targets which don't provide an optimized strcat but which do have an optimized strlen and strcpy, performance gain is > 2x.
This commit is contained in:
@ -1,3 +1,7 @@
|
|||||||
|
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>
|
2014-10-24 Wilco Dijkstra <wdijkstr@arm.com>
|
||||||
|
|
||||||
* sysdeps/aarch64/fpu/fgetexcptflg.c (fegetexceptflag):
|
* sysdeps/aarch64/fpu/fgetexcptflg.c (fegetexceptflag):
|
||||||
|
@ -23,26 +23,7 @@
|
|||||||
char *
|
char *
|
||||||
strcat (char *dest, const char *src)
|
strcat (char *dest, const char *src)
|
||||||
{
|
{
|
||||||
char *s1 = dest;
|
strcpy (dest + strlen (dest), src);
|
||||||
const char *s2 = src;
|
|
||||||
char c;
|
|
||||||
|
|
||||||
/* Find the end of the string. */
|
|
||||||
do
|
|
||||||
c = *s1++;
|
|
||||||
while (c != '\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 != '\0');
|
|
||||||
|
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
libc_hidden_builtin_def (strcat)
|
libc_hidden_builtin_def (strcat)
|
||||||
|
Reference in New Issue
Block a user