]> granicus.if.org Git - apache/commitdiff
Small changes to ap_casecmpstr[n]() for better performances, see:
authorYann Ylavic <ylavic@apache.org>
Tue, 29 Dec 2015 17:13:15 +0000 (17:13 +0000)
committerYann Ylavic <ylavic@apache.org>
Tue, 29 Dec 2015 17:13:15 +0000 (17:13 +0000)
http://mail-archives.apache.org/mod_mbox/httpd-dev/201511.mbox/%3CCAKQ1sVOU7xmY-_PaQb0et0GXO-NxtTPBsD4ZU_UbtUzWYOUVTg%40mail.gmail.com%3E

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1722194 13f79535-47bb-0310-9956-ffa450edef68

server/util.c

index b69df08c60e5e48b1dd1ac513fa47e7c3d5821b1..62299f7c3039325b5504f4be7c9f0bdbfbab096b 100644 (file)
@@ -3264,12 +3264,13 @@ AP_DECLARE(int) ap_casecmpstr(const char *s1, const char *s2)
     const unsigned char *ps1 = (const unsigned char *) s1;
     const unsigned char *ps2 = (const unsigned char *) s2;
 
-    while (ucharmap[*ps1] == ucharmap[*ps2++]) {
+    while (ucharmap[*ps1] == ucharmap[*ps2]) {
         if (*ps1++ == '\0') {
             return (0);
         }
+        ps2++;
     }
-    return (ucharmap[*ps1] - ucharmap[*--ps2]);
+    return (ucharmap[*ps1] - ucharmap[*ps2]);
 }
 
 AP_DECLARE(int) ap_casecmpstrn(const char *s1, const char *s2, apr_size_t n)
@@ -3277,12 +3278,13 @@ AP_DECLARE(int) ap_casecmpstrn(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;
     while (n--) {
-        if (ucharmap[*ps1] != ucharmap[*ps2++]) {
-            return (ucharmap[*ps1] - ucharmap[*--ps2]);
+        if (ucharmap[*ps1] != ucharmap[*ps2]) {
+            return (ucharmap[*ps1] - ucharmap[*ps2]);
         }
         if (*ps1++ == '\0') {
             break;
         }
+        ps2++;
     }
     return (0);
 }