You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mt...@apache.org on 2003/04/23 10:18:00 UTC

cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_map.c

mturk       2003/04/23 01:18:00

  Modified:    jk/native2/common jk_map.c
  Log:
  Add the sort method for table.
  This enables that uri's are sorted in decreasing length order.
  It will speed up the prefix and sufix procssing.
  
  Revision  Changes    Path
  1.27      +45 -2     jakarta-tomcat-connectors/jk/native2/common/jk_map.c
  
  Index: jk_map.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_map.c,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- jk_map.c	4 Mar 2003 07:15:44 -0000	1.26
  +++ jk_map.c	23 Apr 2003 08:18:00 -0000	1.27
  @@ -359,6 +359,49 @@
       return buf;
   }
   
  +void qsort2(char **a, void **d, int n)
  +{
  +    int i, j;
  +    char *x, *w;
  +    
  +    do {
  +        i = 0; j = n - 1;
  +        x = a[j/2];
  +        do {
  +            /* XXX: descending length sorting */
  +            while (strlen(a[i]) > strlen(x)) i++;
  +            while (strlen(a[j]) < strlen(x)) j--;
  +            if (i > j)
  +                break;
  +            w = a[i]; a[i] = a[j]; a[j] = w;
  +            w = d[i]; d[i] = d[j]; d[j] = w;
  +        }
  +        while (++i <= --j);
  +        if (j + 1 < n - i) {
  +            if (j > 0)
  +                qsort2(a, d, j + 1);
  +            a += i; d += i; n -= i;
  +        }
  +        else {
  +            if (i < n - 1) qsort2(a + i, d + i, n - i);
  +            n = j + 1;
  +        }
  +    }
  +    while (n > 1);
  +}
  +
  +
  +
  +static void jk2_map_qsort(jk_env_t *env, jk_map_t *map)
  +{
  +    int n = map->size(env, map);
  +    
  +    if (n < 2)
  +        return;
  +    qsort2(map->keys, map->values, n);
  +}
  +
  +
   
   /* ==================== */
   /* Internal utils */
  @@ -401,7 +444,7 @@
       _this->valueAt=jk2_map_default_valueAt;
       _this->init=jk2_map_default_init;
       _this->clear=jk2_map_default_clear;
  -
  +    _this->sort=jk2_map_qsort;
       return JK_OK;
   }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org