From 38b27b0333e92fefab5dbc7729a164fc6c23ace1 Mon Sep 17 00:00:00 2001 From: Brian Pane Date: Sat, 24 Nov 2001 04:22:45 +0000 Subject: [PATCH] optimize ap_add_common_vars() for the common case where r->subprocess_env is empty git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92152 13f79535-47bb-0310-9956-ffa450edef68 --- server/util_script.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server/util_script.c b/server/util_script.c index 669e283183..61d85d902c 100644 --- a/server/util_script.c +++ b/server/util_script.c @@ -176,8 +176,15 @@ AP_DECLARE(void) ap_add_common_vars(request_rec *r) /* use a temporary apr_table_t which we'll overlap onto * r->subprocess_env later + * (exception: if r->subprocess_env is empty at the start, + * write directly into it) */ - e = apr_table_make(r->pool, 25 + hdrs_arr->nelts); + if (apr_is_empty_table(r->subprocess_env)) { + e = r->subprocess_env; + } + else { + e = apr_table_make(r->pool, 25 + hdrs_arr->nelts); + } /* First, add environment vars from headers... this is as per * CGI specs, though other sorts of scripting interfaces see @@ -297,7 +304,9 @@ AP_DECLARE(void) ap_add_common_vars(request_rec *r) } } - apr_table_overlap(r->subprocess_env, e, APR_OVERLAP_TABLES_SET); + if (e != r->subprocess_env) { + apr_table_overlap(r->subprocess_env, e, APR_OVERLAP_TABLES_SET); + } } /* This "cute" little function comes about because the path info on -- 2.50.1