mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-08 17:42:12 +03:00
Improve performance of strncpy.
This commit is contained in:
@@ -57,10 +57,10 @@ STRNCPY (char *s1, const char *s2, size_t n)
|
||||
if (--n4 == 0)
|
||||
goto last_chars;
|
||||
}
|
||||
n = n - (s1 - s) - 1;
|
||||
if (n == 0)
|
||||
return s;
|
||||
goto zero_fill;
|
||||
s1++;
|
||||
n = n - (s1 - s);
|
||||
memset (s1, '\0', n);
|
||||
return s;
|
||||
}
|
||||
|
||||
last_chars:
|
||||
@@ -77,11 +77,7 @@ STRNCPY (char *s1, const char *s2, size_t n)
|
||||
}
|
||||
while (c != '\0');
|
||||
|
||||
zero_fill:
|
||||
do
|
||||
*++s1 = '\0';
|
||||
while (--n > 0);
|
||||
|
||||
memset (s1 + 1, '\0', n);
|
||||
return s;
|
||||
}
|
||||
libc_hidden_builtin_def (strncpy)
|
||||
|
Reference in New Issue
Block a user