From: Jim Jagielski Date: Sat, 21 Nov 2015 13:57:48 +0000 (+0000) Subject: move to simpler while loop and reduce number of returns X-Git-Tag: 2.5.0-alpha~2623 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0bb8e80ae120306029824e03eabeeb9ff6fdc11b;p=thirdparty%2Fapache%2Fhttpd.git move to simpler while loop and reduce number of returns git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1715526 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/util.c b/server/util.c index 89642a27ca2..aafb68d961e 100644 --- a/server/util.c +++ b/server/util.c @@ -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); }