]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
According top my testing 'socache_mc_id2key' is 6x faster with the use 'ap_bin2hex...
authorChristophe Jaillet <jailletc36@apache.org>
Sun, 6 Jan 2013 17:52:43 +0000 (17:52 +0000)
committerChristophe Jaillet <jailletc36@apache.org>
Sun, 6 Jan 2013 17:52:43 +0000 (17:52 +0000)
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.

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

modules/cache/mod_socache_memcache.c

index ccb1bde76684a3facb46650aedca988b5641810f..beeeec2c982e4c5dbe61b5f4fbe56ec946fdc103 100644 (file)
@@ -182,19 +182,13 @@ static int socache_mc_id2key(ap_socache_instance_t *ctx,
                              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;
 }