From 32c7acd46401530fdbd4e98508c9baaa705f8b53 Mon Sep 17 00:00:00 2001 From: Wilco Dijkstra Date: Fri, 3 Feb 2023 12:01:33 +0000 Subject: 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 --- stdlib/canonicalize.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'stdlib') diff --git a/stdlib/canonicalize.c b/stdlib/canonicalize.c index 78beeef063..7e421ef115 100644 --- a/stdlib/canonicalize.c +++ b/stdlib/canonicalize.c @@ -74,7 +74,6 @@ # endif # define __mempcpy mempcpy # define __pathconf pathconf -# define __rawmemchr rawmemchr # define __readlink readlink # define __stat stat #endif @@ -232,7 +231,7 @@ realpath_stk (const char *name, char *resolved, struct realpath_bufs *bufs) return NULL; rname = bufs->rname.data; } - dest = __rawmemchr (rname, '\0'); + dest = strchr (rname, '\0'); start = name; prefix_len = FILE_SYSTEM_PREFIX_LEN (rname); } -- cgit v1.2.3