]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
move to simpler while loop and reduce number of returns
authorJim Jagielski <jim@apache.org>
Sat, 21 Nov 2015 13:57:48 +0000 (13:57 +0000)
committerJim Jagielski <jim@apache.org>
Sat, 21 Nov 2015 13:57:48 +0000 (13:57 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1715526 13f79535-47bb-0310-9956-ffa450edef68

server/util.c

index 89642a27ca253e40df9a4faf80f877b0074408e8..aafb68d961e7514a277d2492e69318685993f633 100644 (file)
@@ -3228,16 +3228,13 @@ AP_DECLARE(int) ap_strncasecmp(const char *s1, const char *s2, apr_size_t n)
 {
     const unsigned char *ps1 = (const unsigned char *) s1;
     const unsigned char *ps2 = (const unsigned char *) s2;
-    if (n) {
-        do {
-            if (ucharmap[*ps1] != ucharmap[*ps2++]) {
-                return (ucharmap[*ps1] - ucharmap[*--ps2]);
-            }
-            if (*ps1++ == '\0') {
-                /* we know both end here */
-                return (0);
-            }
-        } while (--n != 0);
+    while (n--) {
+        if (ucharmap[*ps1] != ucharmap[*ps2++]) {
+            return (ucharmap[*ps1] - ucharmap[*--ps2]);
+        }
+        if (*ps1++ == '\0') {
+            break;
+        }
     }
     return (0);
 }