From 370406bb4150b07294b257ec320d6e1ee0d39f3a Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Sat, 6 Aug 2016 11:06:29 +0200
Subject: [PATCH] tweaks: don't optimize for a special case -- it is far too
 seldom

---
 src/chars.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/chars.c b/src/chars.c
index 8eed0e54..80904213 100644
--- a/src/chars.c
+++ b/src/chars.c
@@ -514,7 +514,6 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
 
 	while (*s1 != '\0' && *s2 != '\0' && n > 0) {
 	    bool bad1 = FALSE, bad2 = FALSE;
-	    int difference;
 
 	    if (mbtowc(&wc1, s1, MB_CUR_MAX) < 0) {
 		mbtowc_reset();
@@ -532,16 +531,13 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
 
 		if (bad1 != bad2)
 		    return (bad1 ? 1 : -1);
+	    } else {
+		int difference = towlower(wc1) - towlower(wc2);
 
-		s1++; s2++; n--;
-		continue;
+		if (difference != 0)
+		    return difference;
 	    }
 
-	    difference = towlower(wc1) - towlower(wc2);
-
-	    if (difference != 0)
-		return difference;
-
 	    s1 += move_mbright(s1, 0);
 	    s2 += move_mbright(s2, 0);
 	    n--;
-- 
GitLab