public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] newlib: libc: Improved the readability of strpbrk with minor optimization
@ 2023-12-20  6:10 Xiao Zeng
  2023-12-20  6:25 ` Xiao Zeng
  2023-12-20 22:48 ` Jeff Johnston
  0 siblings, 2 replies; 6+ messages in thread
From: Xiao Zeng @ 2023-12-20  6:10 UTC (permalink / raw)
  To: newlib; +Cc: jjohnstn, palmer, jeffreyalaw, torbjorn.svensson, Xiao Zeng

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-12-22  1:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-20  6:10 [PATCH] newlib: libc: Improved the readability of strpbrk with minor optimization Xiao Zeng
2023-12-20  6:25 ` Xiao Zeng
2023-12-20 22:48 ` Jeff Johnston
2023-12-21  1:16   ` Xiao Zeng
2023-12-21 19:05     ` Jeff Johnston
2023-12-22  1:21       ` Xiao Zeng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).