You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by yl...@apache.org on 2015/12/29 18:13:16 UTC

svn commit: r1722194 - /httpd/httpd/trunk/server/util.c

Author: ylavic
Date: Tue Dec 29 17:13:15 2015
New Revision: 1722194

URL: http://svn.apache.org/viewvc?rev=1722194&view=rev
Log:
Small changes to ap_casecmpstr[n]() for better performances, see:
http://mail-archives.apache.org/mod_mbox/httpd-dev/201511.mbox/%3CCAKQ1sVOU7xmY-_PaQb0et0GXO-NxtTPBsD4ZU_UbtUzWYOUVTg%40mail.gmail.com%3E

Modified:
    httpd/httpd/trunk/server/util.c

Modified: httpd/httpd/trunk/server/util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util.c?rev=1722194&r1=1722193&r2=1722194&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util.c (original)
+++ httpd/httpd/trunk/server/util.c Tue Dec 29 17:13:15 2015
@@ -3264,12 +3264,13 @@ AP_DECLARE(int) ap_casecmpstr(const char
     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 cha
     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);
 }