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 --- libio/strops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libio') diff --git a/libio/strops.c b/libio/strops.c index 7e523ad710..b5c850b626 100644 --- a/libio/strops.c +++ b/libio/strops.c @@ -38,7 +38,7 @@ _IO_str_init_static_internal (_IO_strfile *sf, char *ptr, size_t size, char *end; if (size == 0) - end = __rawmemchr (ptr, '\0'); + end = strchr (ptr, '\0'); else if ((size_t) ptr + size > (size_t) ptr) end = ptr + size; else -- cgit 1.4.1