mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
Replace rawmemchr (s, '\0') with strchr
Almost all uses of rawmemchr find the end of a string. Since most targets use a generic implementation, replacing it with strchr is better since that is optimized by compilers into strlen (s) + s. Also fix the generic rawmemchr implementation to use a cast to unsigned char in the if statement. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
@ -39,7 +39,7 @@ DIAG_IGNORE_NEEDS_COMMENT (11, "-Wstringop-overread");
|
||||
void *
|
||||
RAWMEMCHR (const void *s, int c)
|
||||
{
|
||||
if (c != '\0')
|
||||
if ((unsigned char) c != '\0')
|
||||
return memchr (s, c, (size_t)-1);
|
||||
return (char *)s + strlen (s);
|
||||
}
|
||||
|
Reference in New Issue
Block a user