httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davi Arnaut <d...@haxent.com.br>
Subject [patch 05/16] pass uri_meets_conditions values by reference
Date Wed, 20 Sep 2006 02:33:58 GMT
Don't pass 'large' objects by value when not needed, it wastes time and space.

Index: modules/cache/cache_util.c
===================================================================
--- modules/cache/cache_util.c.orig
+++ modules/cache/cache_util.c
@@ -28,40 +28,41 @@
 /* Determine if "url" matches the hostname, scheme and port and path
  * in "filter". All but the path comparisons are case-insensitive.
  */
-static int uri_meets_conditions(apr_uri_t filter, int pathlen, apr_uri_t url)
+static int uri_meets_conditions(const apr_uri_t *filter, apr_size_t pathlen,
+                                const apr_uri_t *url)
 {
     /* Compare the hostnames */
-    if(filter.hostname) {
-        if (!url.hostname) {
+    if(filter->hostname) {
+        if (!url->hostname) {
             return 0;
         }
-        else if (strcasecmp(filter.hostname, url.hostname)) {
+        else if (strcasecmp(filter->hostname, url->hostname)) {
             return 0;
         }
     }
 
     /* Compare the schemes */
-    if(filter.scheme) {
-        if (!url.scheme) {
+    if(filter->scheme) {
+        if (!url->scheme) {
             return 0;
         }
-        else if (strcasecmp(filter.scheme, url.scheme)) {
+        else if (strcasecmp(filter->scheme, url->scheme)) {
             return 0;
         }
     }
 
     /* Compare the ports */
-    if(filter.port_str) {
-        if (url.port_str && filter.port != url.port) {
+    if(filter->port_str) {
+        if (url->port_str && filter->port != url->port) {
             return 0;
         }
         /* NOTE:  ap_port_of_scheme will return 0 if given NULL input */
-        else if (filter.port != apr_uri_port_of_scheme(url.scheme)) {
+        else if (filter->port != apr_uri_port_of_scheme(url->scheme)) {
             return 0;
         }
     }
-    else if(url.port_str && filter.scheme) {
-        if (apr_uri_port_of_scheme(filter.scheme) == url.port) {
+    else if(url->port_str && filter->scheme) {
+        if (apr_uri_port_of_scheme(filter->scheme) == url->port) {
             return 0;
         }
     }
@@ -69,12 +70,11 @@
     /* Url has met all of the filter conditions so far, determine
      * if the paths match.
      */
-    return !strncmp(filter.path, url.path, pathlen);
+    return !strncmp(filter->path, url->path, pathlen);
 }
 
 CACHE_DECLARE(cache_provider_list *)ap_cache_get_providers(request_rec *r,
-                                                  cache_server_conf *conf,
-                                                  apr_uri_t uri)
+                                                  cache_server_conf *conf)
 {
     cache_provider_list *providers = NULL;
     int i;
@@ -83,7 +83,7 @@
     for (i = 0; i < conf->cacheenable->nelts; i++) {
         struct cache_enable *ent =
                                 (struct cache_enable *)conf->cacheenable->elts;
-        if (uri_meets_conditions(ent[i].url, ent[i].pathlen, uri)) {
+        if (uri_meets_conditions(&ent[i].url, ent[i].pathlen, &r->parsed_uri))
{
             /* Fetch from global config and add to the list. */
             cache_provider *provider;
             provider = ap_lookup_provider(CACHE_PROVIDER_GROUP, ent[i].type,
@@ -120,7 +120,7 @@
     for (i = 0; i < conf->cachedisable->nelts; i++) {
         struct cache_disable *ent =
                                (struct cache_disable *)conf->cachedisable->elts;
-        if (uri_meets_conditions(ent[i].url, ent[i].pathlen, uri)) {
+        if (uri_meets_conditions(&ent[i].url, ent[i].pathlen, &r->parsed_uri))
{
             /* Stop searching now. */
             return NULL;
         }
Index: modules/cache/mod_cache.c
===================================================================
--- modules/cache/mod_cache.c.orig
+++ modules/cache/mod_cache.c
@@ -108,7 +108,7 @@
     /*
      * Which cache module (if any) should handle this request?
      */
-    if (!(providers = ap_cache_get_providers(r, conf, r->parsed_uri))) {
+    if (!(providers = ap_cache_get_providers(r, conf))) {
         return DECLINED;
     }
 
Index: modules/cache/mod_cache.h
===================================================================
--- modules/cache/mod_cache.h.orig
+++ modules/cache/mod_cache.h
@@ -280,7 +280,7 @@
                                              unsigned int *dirlevels,
                                              unsigned int *divisors,
                                              const char *name);
-CACHE_DECLARE(cache_provider_list *)ap_cache_get_providers(request_rec *r, cache_server_conf
*conf, apr_uri_t uri);
+CACHE_DECLARE(cache_provider_list *)ap_cache_get_providers(request_rec *r, cache_server_conf
*conf);
 CACHE_DECLARE(int) ap_cache_liststr(apr_pool_t *p, const char *list,
                                     const char *key, char **val);
 CACHE_DECLARE(const char *)ap_cache_tokstr(apr_pool_t *p, const char *list, const char **str);

--

Mime
View raw message