mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Fix strcpy_chk and stpcpy_chk performance.
Hi, as I wrote in previous patches a performance of checked strcpy and stpcpy is terrible as these don't use sse2 and are around four times slower that strcpy and stpcpy now. As this bug shows that these functions are not performance sensitive I decided just to improve generic implementation instead for easier maintainance. * debug/strcpy_chk.c: Improve performance. * debug/stpcpy_chk.c: Likewise. * sysdeps/x86_64/strcpy_chk.S: Remove. * sysdeps/x86_64/stpcpy_chk.S: Remove.
This commit is contained in:
@ -24,21 +24,11 @@
|
||||
|
||||
/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
|
||||
char *
|
||||
__stpcpy_chk (dest, src, destlen)
|
||||
char *dest;
|
||||
const char *src;
|
||||
size_t destlen;
|
||||
__stpcpy_chk (char *dest, const char *src, size_t destlen)
|
||||
{
|
||||
char *d = dest;
|
||||
const char *s = src;
|
||||
size_t len = strlen (src);
|
||||
if (len >= destlen)
|
||||
__chk_fail ();
|
||||
|
||||
do
|
||||
{
|
||||
if (__glibc_unlikely (destlen-- == 0))
|
||||
__chk_fail ();
|
||||
*d++ = *s;
|
||||
}
|
||||
while (*s++ != '\0');
|
||||
|
||||
return d - 1;
|
||||
return memcpy (dest, src, len + 1) + len;
|
||||
}
|
||||
|
Reference in New Issue
Block a user