public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Optimize strpbrk.c
@ 2023-12-21 19:05 Jeff Johnston
  0 siblings, 0 replies; only message in thread
From: Jeff Johnston @ 2023-12-21 19:05 UTC (permalink / raw)
  To: newlib-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=188ca64934e610666bd05186395429bb2407c264

commit 188ca64934e610666bd05186395429bb2407c264
Author: Jeff Johnston <jjohnstn@redhat.com>
Date:   Thu Dec 21 14:04:31 2023 -0500

    Optimize strpbrk.c

Diff:
---
 newlib/libc/string/strpbrk.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/newlib/libc/string/strpbrk.c b/newlib/libc/string/strpbrk.c
index 774db1e6d..d98474564 100644
--- a/newlib/libc/string/strpbrk.c
+++ b/newlib/libc/string/strpbrk.c
@@ -29,23 +29,16 @@ strpbrk (const char *s1,
 	const char *s2)
 {
   const char *c = s2;
-  if (!*s1)
-    return (char *) NULL;
 
   while (*s1)
     {
       for (c = s2; *c; c++)
 	{
 	  if (*s1 == *c)
-	    break;
+	    return (char *) s1;
 	}
-      if (*c)
-	break;
       s1++;
     }
 
-  if (*c == '\0')
-    s1 = NULL;
-
-  return (char *) s1;
+  return (char *) NULL;
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-12-21 19:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-21 19:05 [newlib-cygwin] Optimize strpbrk.c Jeff Johnston

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).