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 --- iconvdata/iso646.c | 2 +- iconvdata/utf-7.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'iconvdata') diff --git a/iconvdata/iso646.c b/iconvdata/iso646.c index e044ed2cba..f7111a3759 100644 --- a/iconvdata/iso646.c +++ b/iconvdata/iso646.c @@ -133,7 +133,7 @@ gconv_init (struct __gconv_step *step) enum variant var = 0; for (const char *name = names; *name != '\0'; - name = __rawmemchr (name, '\0') + 1) + name = strchr (name, '\0') + 1) { if (__strcasecmp (step->__from_name, name) == 0) { diff --git a/iconvdata/utf-7.c b/iconvdata/utf-7.c index 198ba99c2b..babeb56f4e 100644 --- a/iconvdata/utf-7.c +++ b/iconvdata/utf-7.c @@ -189,7 +189,7 @@ gconv_init (struct __gconv_step *step) enum variant var = 0; for (const char *name = names; *name != '\0'; - name = __rawmemchr (name, '\0') + 1) + name = strchr (name, '\0') + 1) { if (__strcasecmp (step->__from_name, name) == 0) { -- cgit 1.4.1