mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] strcmp: Remove unnecessary check for *r
@ 2013-11-05  5:48 Michael Forney
  0 siblings, 0 replies; only message in thread
From: Michael Forney @ 2013-11-05  5:48 UTC (permalink / raw)
  To: musl

If *l == *r && *l, then by transitivity, *r.
---
I noticed while looking at getopt_long that strcmp has a redundant check for
*r. I know the compiler will almost certainly optimize this out anyway, but I
still think it would be a good change to make.

 src/string/strcmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/string/strcmp.c b/src/string/strcmp.c
index 91eb740..808bd83 100644
--- a/src/string/strcmp.c
+++ b/src/string/strcmp.c
@@ -2,6 +2,6 @@
 
 int strcmp(const char *l, const char *r)
 {
-	for (; *l==*r && *l && *r; l++, r++);
+	for (; *l==*r && *l; l++, r++);
 	return *(unsigned char *)l - *(unsigned char *)r;
 }
-- 
1.8.4.2



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

only message in thread, other threads:[~2013-11-05  5:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-05  5:48 [PATCH] strcmp: Remove unnecessary check for *r Michael Forney

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).