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 Tue, 29 Jul 2003 21:38:00 GMT
nd          2003/07/29 14:38:00

  Modified:    modules/mappers mod_rewrite.c
  Log:
  minor optimization: the bracket search functions just search
  for curly brackets, so there's no need to supply that every
  time again.
  
  Revision  Changes    Path
  1.202     +17 -11    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.201
  retrieving revision 1.202
  diff -u -r1.201 -r1.202
  --- mod_rewrite.c	29 Jul 2003 21:01:37 -0000	1.201
  +++ mod_rewrite.c	29 Jul 2003 21:37:59 -0000	1.202
  @@ -225,6 +225,10 @@
   #define REWRITE_MAX_PRG_MAP_LINE 2048
   #endif
   
  +/* for better readbility */
  +#define LEFT_CURLY  '{'
  +#define RIGHT_CURLY '}'
  +
   /*
    * +-------------------------------------------------------+
    * |                                                       |
  @@ -1858,36 +1862,38 @@
    * Bracketed expression handling
    * s points after the opening bracket
    */
  -static char *find_closing_bracket(char *s, int left, int right)
  +static char *find_closing_curly(char *s)
   {
  -    int depth;
  +    unsigned depth;
   
       for (depth = 1; *s; ++s) {
  -        if (*s == right && --depth == 0) {
  +        if (*s == RIGHT_CURLY && --depth == 0) {
               return s;
           }
  -        else if (*s == left) {
  +        else if (*s == LEFT_CURLY) {
               ++depth;
           }
       }
  +
       return NULL;
   }
   
  -static char *find_char_in_brackets(char *s, int c, int left, int right)
  +static char *find_char_in_curlies(char *s, int c)
   {
  -    int depth;
  +    unsigned depth;
   
       for (depth = 1; *s; ++s) {
           if (*s == c && depth == 1) {
               return s;
           }
  -        else if (*s == right && --depth == 0) {
  +        else if (*s == RIGHT_CURLY && --depth == 0) {
               return NULL;
           }
  -        else if (*s == left) {
  +        else if (*s == LEFT_CURLY) {
               ++depth;
           }
       }
  +
       return NULL;
   }
   
  @@ -1952,7 +1958,7 @@
           else if (p[1] == '{') {
               char *endp;
   
  -            endp = find_closing_bracket(p+2, '{', '}');
  +            endp = find_closing_curly(p+2);
               if (!endp) {
                   current->len = 2;
                   current->string = p;
  @@ -1988,7 +1994,7 @@
                    * driven by the syntax of the nested curly brackets.
                    */
   
  -                key = find_char_in_brackets(p+2, ':', '{', '}');
  +                key = find_char_in_curlies(p+2, ':');
                   if (!key) {
                       current->len = 2;
                       current->string = p;
  @@ -2001,7 +2007,7 @@
                       map = apr_pstrmemdup(r->pool, p+2, endp-p-2);
                       key = map + (key-p-2);
                       *key++ = '\0';
  -                    dflt = find_char_in_brackets(key, '|', '{', '}');
  +                    dflt = find_char_in_curlies(key, '|');
                       if (dflt) {
                           *dflt++ = '\0';
                       }
  
  
  

Mime
View raw message