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 2017/03/27 19:48:20 UTC

svn commit: r1788996 - /httpd/httpd/trunk/modules/cache/mod_cache_socache.c

Author: jailletc36
Date: Mon Mar 27 19:48:19 2017
New Revision: 1788996

URL: http://svn.apache.org/viewvc?rev=1788996&view=rev
Log:
Save a few cycles.
'apr_pstrcatv' can compute the length of the new string for us.

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

Modified: httpd/httpd/trunk/modules/cache/mod_cache_socache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_cache_socache.c?rev=1788996&r1=1788995&r2=1788996&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_cache_socache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_cache_socache.c Mon Mar 27 19:48:19 2017
@@ -270,7 +270,8 @@ static apr_status_t store_table(apr_tabl
 }
 
 static const char* regen_key(apr_pool_t *p, apr_table_t *headers,
-        apr_array_header_t *varray, const char *oldkey)
+                             apr_array_header_t *varray, const char *oldkey,
+                             apr_size_t *newkeylen)
 {
     struct iovec *iov;
     int i, k;
@@ -322,7 +323,7 @@ static const char* regen_key(apr_pool_t
     iov[k].iov_len = strlen(oldkey);
     k++;
 
-    return apr_pstrcatv(p, iov, k, NULL);
+    return apr_pstrcatv(p, iov, k, newkeylen);
 }
 
 static int array_alphasort(const void *fn1, const void *fn2)
@@ -526,7 +527,7 @@ static int open_entity(cache_handle_t *h
             return DECLINED;
         }
 
-        nkey = regen_key(r->pool, r->headers_in, varray, key);
+        nkey = regen_key(r->pool, r->headers_in, varray, key, &len);
 
         /* attempt to retrieve the cached entry */
         if (socache_mutex) {
@@ -542,7 +543,7 @@ static int open_entity(cache_handle_t *h
         buffer_len = sobj->buffer_len;
         rc = conf->provider->socache_provider->retrieve(
                 conf->provider->socache_instance, r->server,
-                (unsigned char *) nkey, strlen(nkey), sobj->buffer,
+                (unsigned char *) nkey, len, sobj->buffer,
                 &buffer_len, r->pool);
         if (socache_mutex) {
             apr_status_t status = apr_global_mutex_unlock(socache_mutex);
@@ -869,7 +870,7 @@ static apr_status_t store_headers(cache_
             }
 
             obj->key = sobj->key = regen_key(r->pool, sobj->headers_in, varray,
-                    sobj->name);
+                                             sobj->name, NULL);
         }
     }