httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n.@apache.org
Subject cvs commit: httpd-2.0/modules/mappers mod_rewrite.c
Date Mon, 04 Aug 2003 21:47:08 GMT
nd          2003/08/04 14:47:08

  Modified:    modules/mappers mod_rewrite.c
  Log:
  improve expansion performance.
  If we have only small expansions (like just one variable - often used
  in map keys or the like), don't stress the pool with allocating
  memory for the linked result pointer list. This list can be safely
  stored on the stack.
  
  Revision  Changes    Path
  1.216     +16 -3     httpd-2.0/modules/mappers/mod_rewrite.c
  
  Index: mod_rewrite.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_rewrite.c,v
  retrieving revision 1.215
  retrieving revision 1.216
  diff -u -r1.215 -r1.216
  --- mod_rewrite.c	3 Aug 2003 20:15:50 -0000	1.215
  +++ mod_rewrite.c	4 Aug 2003 21:47:08 -0000	1.216
  @@ -225,6 +225,13 @@
   #define RIGHT_CURLY '}'
   
   /*
  + * expansion result items on the stack to save some cycles
  + *
  + * (5 == about 2 variables like "foo%{var}bar%{var}baz")
  + */
  +#define SMALL_EXPANSION 5
  +
  +/*
    * check that a subrequest won't cause infinite recursion
    *
    * either not in a subrequest, or in a subrequest
  @@ -1922,6 +1929,8 @@
                          backrefinfo *briRR, backrefinfo *briRC)
   {
       result_list *result, *current;
  +    result_list sresult[SMALL_EXPANSION];
  +    unsigned spc = 0;
       apr_size_t span, inputlen, outlen;
       char *p, *c;
   
  @@ -1934,7 +1943,7 @@
       }
   
       /* well, actually something to do */
  -    result = current = apr_palloc(r->pool, sizeof(result_list));
  +    result = current = &(sresult[spc++]);
   
       p = input + span;
       current->next = NULL;
  @@ -1946,7 +1955,9 @@
       do {
           /* prepare next entry */
           if (current->len) {
  -            current->next = apr_palloc(r->pool, sizeof(result_list));
  +            current->next = (spc < SMALL_EXPANSION)
  +                            ? &(sresult[spc++])
  +                            : apr_palloc(r->pool, sizeof(result_list));
               current = current->next;
               current->next = NULL;
               current->len = 0;
  @@ -2074,7 +2085,9 @@
           /* check the remainder */
           if (*p && (span = strcspn(p, "\\$%")) > 0) {
               if (current->len) {
  -                current->next = apr_palloc(r->pool, sizeof(result_list));
  +                current->next = (spc < SMALL_EXPANSION)
  +                                ? &(sresult[spc++])
  +                                : apr_palloc(r->pool, sizeof(result_list));
                   current = current->next;
                   current->next = NULL;
               }
  
  
  

Mime
View raw message