Improve performance of strncpy.
This commit is contained in:
parent
b863d2bc4d
commit
6423d4754c
|
@ -1,4 +1,8 @@
|
||||||
2014-09-23 Wilco Dijkstra <wdijkstr@arm.com>
|
2014-11-24 Wilco Dijkstra <wdijkstr@arm.com>
|
||||||
|
|
||||||
|
* string/strncpy.c (strncpy): Improve performance by using memset.
|
||||||
|
|
||||||
|
2014-11-24 Wilco Dijkstra <wdijkstr@arm.com>
|
||||||
|
|
||||||
* string/strcpy.c (strcpy):
|
* string/strcpy.c (strcpy):
|
||||||
Improve performance by using strlen and memcpy.
|
Improve performance by using strlen and memcpy.
|
||||||
|
|
|
@ -57,10 +57,10 @@ STRNCPY (char *s1, const char *s2, size_t n)
|
||||||
if (--n4 == 0)
|
if (--n4 == 0)
|
||||||
goto last_chars;
|
goto last_chars;
|
||||||
}
|
}
|
||||||
n = n - (s1 - s) - 1;
|
s1++;
|
||||||
if (n == 0)
|
n = n - (s1 - s);
|
||||||
return s;
|
memset (s1, '\0', n);
|
||||||
goto zero_fill;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
last_chars:
|
last_chars:
|
||||||
|
@ -77,11 +77,7 @@ STRNCPY (char *s1, const char *s2, size_t n)
|
||||||
}
|
}
|
||||||
while (c != '\0');
|
while (c != '\0');
|
||||||
|
|
||||||
zero_fill:
|
memset (s1 + 1, '\0', n);
|
||||||
do
|
|
||||||
*++s1 = '\0';
|
|
||||||
while (--n > 0);
|
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
libc_hidden_builtin_def (strncpy)
|
libc_hidden_builtin_def (strncpy)
|
||||||
|
|
Loading…
Reference in a new issue