apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject cvs commit: apr/tables apr_tables.c
Date Sat, 27 Jul 2002 23:43:20 GMT
brianp      2002/07/27 16:43:20

  Modified:    tables   apr_tables.c
  Log:
  Optimization for apr_table_overlap(): because the destination
  array is pre-allocated to ensure that it's big enough to hold
  the result table, just use simple pointer arithmetic to write
  to successive elements, rather than calling the array push
  function
  
  Revision  Changes    Path
  1.41      +11 -8     apr/tables/apr_tables.c
  
  Index: apr_tables.c
  ===================================================================
  RCS file: /home/cvs/apr/tables/apr_tables.c,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- apr_tables.c	27 Jul 2002 22:59:20 -0000	1.40
  +++ apr_tables.c	27 Jul 2002 23:43:20 -0000	1.41
  @@ -1211,6 +1211,7 @@
       int nhash;
       int i;
       apr_table_entry_t *elts;
  +    apr_table_entry_t *dst_elt;
   
       max_keys = a->a.nelts + b->a.nelts;
       if (!max_keys) {
  @@ -1265,6 +1266,7 @@
        */
       make_array_core(&a->a, b->a.pool, max_keys, sizeof(apr_table_entry_t), 0);
       nkeys = 0;
  +    dst_elt = (apr_table_entry_t *)a->a.elts;
       for (i = 0; i < max_keys; i++) {
           if (cat_keys[i].skip) {
               continue;
  @@ -1301,18 +1303,19 @@
                   next = next->merge_next;
               } while (next);
               *val_next = 0;
  -            elt = (apr_table_entry_t *)table_push(a);
  -            elt->key = cat_keys[i].elt->key;
  -            elt->val = new_val;
  -            elt->key_checksum = cat_keys[i].elt->key_checksum;
  +            dst_elt->key = cat_keys[i].elt->key;
  +            dst_elt->val = new_val;
  +            dst_elt->key_checksum = cat_keys[i].elt->key_checksum;
  +            dst_elt++;
           }
           else {
  -            apr_table_entry_t *elt = (apr_table_entry_t *)table_push(a);
  -            elt->key = cat_keys[i].elt->key;
  -            elt->val = cat_keys[i].elt->val;
  -            elt->key_checksum = cat_keys[i].elt->key_checksum;
  +            dst_elt->key = cat_keys[i].elt->key;
  +            dst_elt->val = cat_keys[i].elt->val;
  +            dst_elt->key_checksum = cat_keys[i].elt->key_checksum;
  +            dst_elt++;
           }
       }
  +    a->a.nelts = dst_elt - (apr_table_entry_t *)a->a.elts;
       table_reindex(a);
   }
   
  
  
  

Mime
View raw message