You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ja...@apache.org on 2013/01/06 18:52:44 UTC

svn commit: r1429561 - /httpd/httpd/trunk/modules/cache/mod_socache_memcache.c

Author: jailletc36
Date: Sun Jan  6 17:52:43 2013
New Revision: 1429561

URL: http://svn.apache.org/viewvc?rev=1429561&view=rev
Log:
According top my testing 'socache_mc_id2key' is 6x faster with the use 'ap_bin2hex' instead of
apr_snprintf(..., "%02X" for each character.
Output is *not* exactly the same. It was uppercase, now it is lowercase.

According to my understanding, this is not an issue.
Should it be, a call to ap_str_toupper should be added.

The speedup would be less, but still significant.

Modified:
    httpd/httpd/trunk/modules/cache/mod_socache_memcache.c

Modified: httpd/httpd/trunk/modules/cache/mod_socache_memcache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_socache_memcache.c?rev=1429561&r1=1429560&r2=1429561&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_socache_memcache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_socache_memcache.c Sun Jan  6 17:52:43 2013
@@ -182,19 +182,13 @@ static int socache_mc_id2key(ap_socache_
                              char *key, apr_size_t keylen)
 {
     char *cp;
-    unsigned int n;
 
     if (idlen * 2 + ctx->taglen >= keylen)
         return 1;
 
     cp = apr_cpystrn(key, ctx->tag, ctx->taglen);
+    ap_bin2hex(id, idlen, cp);
 
-    for (n = 0; n < idlen; n++) {
-        apr_snprintf(cp, 3, "%02X", (unsigned) id[n]);
-        cp += 2;
-    }
-
-    *cp = '\0';
     return 0;
 }