You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by wr...@apache.org on 2016/06/08 22:39:58 UTC

svn commit: r1747461 - /apr/apr/trunk/strings/apr_cstr.c

Author: wrowe
Date: Wed Jun  8 22:39:58 2016
New Revision: 1747461

URL: http://svn.apache.org/viewvc?rev=1747461&view=rev
Log:
Upon closer scrutiny, the optimization of using short variables
(as opposed to the array of shorts) really didn't hold up.
Revert back to processing in 'int' amounts, persist in using
short values in the character case folding table, which are
more easily retrieved based on word alignment.  Aligning and
representing the table values as 'int' doesn't exhibit any
additional benefit and wastes some DATA page space.


Modified:
    apr/apr/trunk/strings/apr_cstr.c

Modified: apr/apr/trunk/strings/apr_cstr.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/strings/apr_cstr.c?rev=1747461&r1=1747460&r2=1747461&view=diff
==============================================================================
--- apr/apr/trunk/strings/apr_cstr.c (original)
+++ apr/apr/trunk/strings/apr_cstr.c Wed Jun  8 22:39:58 2016
@@ -279,13 +279,15 @@ static const short ucharmap[] = {
 };
 #endif
 
-int apr_cstr_casecmp(const char *str1, const char *str2)
+int apr_cstr_casecmp(const char *s1, const char *s2)
 {
+    const unsigned char *str1 = (const unsigned char *)s1;
+    const unsigned char *str2 = (const unsigned char *)s2;
     for (;;)
     {
-        const short c1 = (short)(*((const unsigned char *)str1));
-        const short c2 = (short)(*((const unsigned char *)str2));
-        const short cmp = ucharmap[c1] - ucharmap[c2];
+        const int c1 = (int)(*str1);
+        const int c2 = (int)(*str2);
+        const int cmp = ucharmap[c1] - ucharmap[c2];
         /* Not necessary to test for !c2, this is caught by cmp */
         if (cmp || !c1)
             return cmp;
@@ -294,13 +296,15 @@ int apr_cstr_casecmp(const char *str1, c
     }
 }
 
-int apr_cstr_casecmpn(const char *str1, const char *str2, apr_size_t n)
+int apr_cstr_casecmpn(const char *s1, const char *s2, apr_size_t n)
 {
+    const unsigned char *str1 = (const unsigned char *)s1;
+    const unsigned char *str2 = (const unsigned char *)s2;
     while (n--)
     {
-        const short c1 = (short)(*((const unsigned char *)str1));
-        const short c2 = (short)(*((const unsigned char *)str2));
-        const short cmp = ucharmap[c1] - ucharmap[c2];
+        const int c1 = (int)(*str1);
+        const int c2 = (int)(*str2);
+        const int cmp = ucharmap[c1] - ucharmap[c2];
         /* Not necessary to test for !c2, this is caught by cmp */
         if (cmp || !c1)
             return cmp;