diff options
author | Christophe Jaillet <jailletc36@apache.org> | 2015-12-10 07:52:10 +0100 |
---|---|---|
committer | Christophe Jaillet <jailletc36@apache.org> | 2015-12-10 07:52:10 +0100 |
commit | ee9f87c2c27ca81a2c7ff776bbc2ccceb2f6b39e (patch) | |
tree | 42bbdb1a756f7d4a74fc393d812cb3675fc5d178 /server/util_regex.c | |
parent | There is no need to duplicate some memory here, the 'path' given to ap_parse... (diff) | |
download | apache2-ee9f87c2c27ca81a2c7ff776bbc2ccceb2f6b39e.tar.xz apache2-ee9f87c2c27ca81a2c7ff776bbc2ccceb2f6b39e.zip |
Use 'apr_pstrmemdup' instead of 'apr_pstrndup' when applicable in order to save a few cycles.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1719018 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server/util_regex.c')
-rw-r--r-- | server/util_regex.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/server/util_regex.c b/server/util_regex.c index 81eac5308d..2a30d68176 100644 --- a/server/util_regex.c +++ b/server/util_regex.c @@ -46,6 +46,7 @@ AP_DECLARE(ap_rxplus_t*) ap_rxplus_compile(apr_pool_t *pool, ap_rxplus_t *ret = apr_pcalloc(pool, sizeof(ap_rxplus_t)); char delim = 0; enum { SUBSTITUTE = 's', MATCH = 'm'} action = MATCH; + if (!apr_isalnum(pattern[0])) { delim = *str++; } @@ -65,7 +66,7 @@ AP_DECLARE(ap_rxplus_t*) ap_rxplus_compile(apr_pool_t *pool, if (delim) { endp = ap_strchr_c(str, delim); } - if (!endp) { /* there's no delim or flags */ + if (!endp) { /* there's no delim or flags */ if (ap_regcomp(&ret->rx, pattern, 0) == 0) { apr_pool_cleanup_register(pool, &ret->rx, rxplus_cleanup, apr_pool_cleanup_null); @@ -77,7 +78,7 @@ AP_DECLARE(ap_rxplus_t*) ap_rxplus_compile(apr_pool_t *pool, } /* We have a delimiter. Use it to extract the regexp */ - rxstr = apr_pstrndup(pool, str, endp-str); + rxstr = apr_pstrmemdup(pool, str, endp-str); /* If it's a substitution, we need the replacement string * TODO: possible future enhancement - support other parsing @@ -89,7 +90,7 @@ AP_DECLARE(ap_rxplus_t*) ap_rxplus_compile(apr_pool_t *pool, /* missing replacement string is an error */ return NULL; } - ret->subs = apr_pstrndup(pool, str, (endp-str)); + ret->subs = apr_pstrmemdup(pool, str, endp-str); } /* anything after the current delimiter is flags */ |