]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Save a few cycles.
authorChristophe Jaillet <jailletc36@apache.org>
Mon, 27 Mar 2017 19:48:19 +0000 (19:48 +0000)
committerChristophe Jaillet <jailletc36@apache.org>
Mon, 27 Mar 2017 19:48:19 +0000 (19:48 +0000)
'apr_pstrcatv' can compute the length of the new string for us.

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

modules/cache/mod_cache_socache.c

index 09b782366188aae636e342ac4d61d00ef08a0b44..9875ce28226cf393a367160b834cd8b6260c0fbb 100644 (file)
@@ -270,7 +270,8 @@ static apr_status_t store_table(apr_table_t *table, unsigned char *buffer,
 }
 
 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 *p, apr_table_t *headers,
     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, request_rec *r, const char *key)
             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, request_rec *r, const char *key)
         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_handle_t *h, request_rec *r,
             }
 
             obj->key = sobj->key = regen_key(r->pool, sobj->headers_in, varray,
-                    sobj->name);
+                                             sobj->name, NULL);
         }
     }