Return-Path: Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 12175 invoked by uid 500); 10 Nov 2001 09:41:57 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 12163 invoked from network); 10 Nov 2001 09:41:57 -0000 Date: Fri, 09 Nov 2001 22:17:16 -0800 From: Brian Pane Subject: [PATCH] http2env optimization To: dev@httpd.apache.org Message-id: <3BECC66C.3020708@pacbell.net> MIME-version: 1.0 Content-type: multipart/mixed; boundary="Boundary_(ID_24GoXFdKbI4//Un4ME0Y4w)" X-Accept-Language: en-us User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.5) Gecko/20011012 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. --Boundary_(ID_24GoXFdKbI4//Un4ME0Y4w) Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT When using modules that call ap_add_common_vars, like mod_include or mod_cgi, the function http2env gets called a lot. This patch cuts the function's work roughly in half. --Brian --Boundary_(ID_24GoXFdKbI4//Un4ME0Y4w) Content-type: text/plain; name=util_script_patch Content-transfer-encoding: 7BIT Content-disposition: inline; filename=util_script_patch Index: server/util_script.c =================================================================== RCS file: /home/cvspublic/httpd-2.0/server/util_script.c,v retrieving revision 1.64 diff -u -r1.64 util_script.c --- server/util_script.c 2001/09/24 21:09:06 1.64 +++ server/util_script.c 2001/11/10 06:02:13 @@ -95,19 +95,26 @@ #define MALFORMED_MESSAGE "malformed header from script. Bad header=" #define MALFORMED_HEADER_LENGTH_TO_SHOW 30 -static char *http2env(apr_pool_t *a, char *w) +static char *http2env(apr_pool_t *a, const char *w) { - char *res = apr_pstrcat(a, "HTTP_", w, NULL); + char *res = (char *)apr_palloc(a, 6 + strlen(w)); char *cp = res; + char c; + *cp++ = 'H'; + *cp++ = 'T'; + *cp++ = 'T'; + *cp++ = 'P'; + *cp++ = '_'; - while (*++cp) { - if (!apr_isalnum(*cp) && *cp != '_') { - *cp = '_'; + while ((c = *w++) != 0) { + if (!apr_isalnum(c)) { + *cp++ = '_'; } else { - *cp = apr_toupper(*cp); + *cp++ = apr_toupper(c); } } + *cp = 0; return res; } --Boundary_(ID_24GoXFdKbI4//Un4ME0Y4w)--