httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i...@apache.org
Subject cvs commit: httpd-2.0/modules/http mod_mime.c
Date Fri, 09 Nov 2001 23:15:44 GMT
ianh        01/11/09 15:15:43

  Modified:    .        CHANGES
               modules/http mod_mime.c
  Log:
  use the new 'apr_hash_merge' function to do the overlays.
  In our testing this resulting in a large performance win (>5%)
  
  Submitted by:	 Brian Pane <bpane@pacbell.net>
  Reviewed by:	Ian Holsman
  
  Revision  Changes    Path
  1.424     +3 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.423
  retrieving revision 1.424
  diff -u -r1.423 -r1.424
  --- CHANGES	2001/11/08 19:44:39	1.423
  +++ CHANGES	2001/11/09 23:15:42	1.424
  @@ -1,5 +1,8 @@
   Changes with Apache 2.0.29-dev
   
  +  *) use new 'apr_hash_merge' function in mod_mime (performance fix)
  +     [Brian Pane <bpane@pacbell.net>]
  +
   Changes with Apache 2.0.28
   
     *) When no port is given in a "ServerName host" directive, the
  
  
  
  1.69      +40 -53    httpd-2.0/modules/http/mod_mime.c
  
  Index: mod_mime.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/http/mod_mime.c,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- mod_mime.c	2001/10/15 02:39:37	1.68
  +++ mod_mime.c	2001/11/09 23:15:43	1.69
  @@ -166,52 +166,41 @@
   /*
    * Overlay one hash table of extension_mappings onto another
    */
  -static void overlay_extension_mappings(apr_pool_t *p,
  -                                       apr_hash_t *overlay, apr_hash_t *base)
  +static void *overlay_extension_mappings(apr_pool_t *p,
  +                                        const void *key,
  +                                        apr_ssize_t klen,
  +                                        const void *overlay_val,
  +                                        const void *base_val,
  +                                        const void *data)
   {
  -    apr_hash_index_t *index;
  -    for (index = apr_hash_first(p, overlay); index;
  -         index = apr_hash_next(index)) {
  -        char *key;
  -        apr_ssize_t klen;
  -        extension_info *overlay_info, *base_info;
  -        
  -        apr_hash_this(index, (const void**)&key, &klen, (void**)&overlay_info);
  -
  -        base_info = (extension_info*)apr_hash_get(base, key, klen);
  -
  -        if (base_info) {
  -            extension_info *copyinfo = base_info;
  -            base_info = (extension_info*)apr_palloc(p, sizeof(*base_info));
  -            apr_hash_set(base, key, klen, base_info);
  -            memcpy(base_info, copyinfo, sizeof(*base_info));
  -
  -            if (overlay_info->forced_type) {
  -                base_info->forced_type = overlay_info->forced_type;
  -            }
  -            if (overlay_info->encoding_type) {
  -                base_info->encoding_type = overlay_info->encoding_type;
  -            }
  -            if (overlay_info->language_type) {
  -                base_info->language_type = overlay_info->language_type;
  -            }
  -            if (overlay_info->handler) {
  -                base_info->handler = overlay_info->handler;
  -            }
  -            if (overlay_info->charset_type) {
  -                base_info->charset_type = overlay_info->charset_type;
  -            }
  -            if (overlay_info->input_filters) {
  -                base_info->input_filters = overlay_info->input_filters;
  -            }
  -            if (overlay_info->output_filters) {
  -                base_info->output_filters = overlay_info->output_filters;
  -            }
  -        }
  -        else {
  -            apr_hash_set(base, key, klen, overlay_info);
  -        }
  +    extension_info *new_info = apr_palloc(p, sizeof(extension_info));
  +    const extension_info *overlay_info = (const extension_info *)overlay_val;
  +    const extension_info *base_info = (const extension_info *)base_val;
  +
  +    memcpy(new_info, base_info, sizeof(extension_info));
  +    if (overlay_info->forced_type) {
  +        new_info->forced_type = overlay_info->forced_type;
  +    }
  +    if (overlay_info->encoding_type) {
  +        new_info->encoding_type = overlay_info->encoding_type;
  +    }
  +    if (overlay_info->language_type) {
  +        new_info->language_type = overlay_info->language_type;
       }
  +    if (overlay_info->handler) {
  +        new_info->handler = overlay_info->handler;
  +    }
  +    if (overlay_info->charset_type) {
  +        new_info->charset_type = overlay_info->charset_type;
  +    }
  +    if (overlay_info->input_filters) {
  +        new_info->input_filters = overlay_info->input_filters;
  +    }
  +    if (overlay_info->output_filters) {
  +        new_info->output_filters = overlay_info->output_filters;
  +    }
  +
  +    return new_info;
   }
   
   /* Member is the offset within an extension_info of the pointer to reset 
  @@ -244,11 +233,10 @@
       mime_dir_config *new = apr_palloc(p, sizeof(mime_dir_config));
   
       if (base->extension_mappings && add->extension_mappings) {
  -        new->extension_mappings = apr_hash_make(p);
  -        overlay_extension_mappings(p, base->extension_mappings,
  -                                   new->extension_mappings);
  -        overlay_extension_mappings(p, add->extension_mappings,
  -                                   new->extension_mappings);
  +        new->extension_mappings = apr_hash_merge(p, add->extension_mappings,
  +                                                 base->extension_mappings,
  +                                                 overlay_extension_mappings,
  +                                                 NULL);
       }
       else {
           if (base->extension_mappings == NULL) {
  @@ -262,9 +250,8 @@
            * We must have a copy for safety.
            */
           if (new->extension_mappings && add->remove_mappings) {
  -            apr_hash_t *copyhash = new->extension_mappings;
  -            new->extension_mappings = apr_hash_make(p);
  -            overlay_extension_mappings(p, copyhash, new->extension_mappings);
  +            new->extension_mappings =
  +                apr_hash_copy(p, new->extension_mappings);
           }
       }
   
  @@ -764,7 +751,7 @@
       /* Parse filename extensions which can be in any order 
        */
       while (*fn && (ext = ap_getword(r->pool, &fn, '.'))) {
  -        extension_info *exinfo = NULL;
  +        const extension_info *exinfo = NULL;
           int found;
   
           if (*ext == '\0')  /* ignore empty extensions "bad..html" */
  
  
  

Mime
View raw message