apr_pool_t *tmp_pool)
{
int i;
+ int force_quick = 0;
ap_regmatch_t regm[AP_MAX_REG_MATCH];
apr_size_t bytes;
apr_size_t len;
apr_pool_create(&tpool, tmp_pool);
scratch = NULL;
fbytes = 0;
+ /*
+ * Simple optimization. If we only have one pattern, then
+ * we can safely avoid the overhead of flattening
+ */
+ if (cfg->patterns->nelts == 1) {
+ force_quick = 1;
+ }
for (i = 0; i < cfg->patterns->nelts; i++) {
for (b = APR_BRIGADE_FIRST(mybb);
b != APR_BRIGADE_SENTINEL(mybb);
{
/* get offset into buff for pattern */
len = (apr_size_t) (repl - buff);
- if (script->flatten) {
+ if (script->flatten && !force_quick) {
/*
* We are flattening the buckets here, meaning
* that we don't do the fast bucket splits.
bytes -= len;
buff += len;
}
- if (script->flatten && s1) {
+ if (script->flatten && s1 && !force_quick) {
/*
* we've finished looking at the bucket, so remove the
* old one and add in our new one
/* first, grab the replacement string */
repl = ap_pregsub(tmp_pool, script->replacement, p,
AP_MAX_REG_MATCH, regm);
- if (script->flatten) {
+ if (script->flatten && !force_quick) {
SEDSCAT(s1, s2, tmp_pool, p, regm[0].rm_so, repl);
}
else {
*/
p += regm[0].rm_eo;
}
- if (script->flatten && s1) {
+ if (script->flatten && s1 && !force_quick) {
s1 = apr_pstrcat(tmp_pool, s1, p, NULL);
tmp_b = apr_bucket_transient_create(s1, strlen(s1),
f->r->connection->bucket_alloc);