[PATCH] newlib: libc: Improved the readability of strpbrk with minor optimization

Xiao Zeng zengxiao@eswincomputing.com
Wed Dec 20 06:10:54 GMT 2023


Signed-off-by: Xiao Zeng <zengxiao@eswincomputing.com>
---
 newlib/libc/string/strpbrk.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/newlib/libc/string/strpbrk.c b/newlib/libc/string/strpbrk.c
index 774db1e6d..95e89c20c 100644
--- a/newlib/libc/string/strpbrk.c
+++ b/newlib/libc/string/strpbrk.c
@@ -37,15 +37,14 @@ strpbrk (const char *s1,
       for (c = s2; *c; c++)
 	{
 	  if (*s1 == *c)
-	    break;
+	    goto end;
 	}
-      if (*c)
-	break;
       s1++;
     }
 
   if (*c == '\0')
     s1 = NULL;
 
+end:
   return (char *) s1;
 }
-- 
2.17.1



More information about the Newlib mailing list