projects
/
metaproxy-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Avoid re allocations
[metaproxy-moved-to-github.git]
/
src
/
filter_http_rewrite.cpp
diff --git
a/src/filter_http_rewrite.cpp
b/src/filter_http_rewrite.cpp
index
ff1a25c
..
249a757
100644
(file)
--- a/
src/filter_http_rewrite.cpp
+++ b/
src/filter_http_rewrite.cpp
@@
-200,22
+200,22
@@
const std::string yf::HttpRewrite::search_replace(
= groups_bynum.find(i);
if (it != groups_bynum.end())
{ //it is
= groups_bynum.find(i);
if (it != groups_bynum.end())
{ //it is
- std::string name = it->second;
if (!what[i].str().empty())
if (!what[i].str().empty())
- vars[name] = what[i];
+ vars[it->second] = what[i];
}
}
//prepare replacement string
std::string rvalue = sub_vars(uri_pat, vars);
}
}
//prepare replacement string
std::string rvalue = sub_vars(uri_pat, vars);
- //rewrite value
- std::string rhvalue = what.prefix().str()
- + rvalue + what.suffix().str();
yaz_log(YLOG_LOG, "! Rewritten '%s' to '%s'",
what.str(0).c_str(), rvalue.c_str());
yaz_log(YLOG_LOG, "! Rewritten '%s' to '%s'",
what.str(0).c_str(), rvalue.c_str());
- out += rhvalue;
+ out.append(start, what[0].first);
+ out.append(rvalue);
start = what[0].second; //move search forward
}
start = what[0].second; //move search forward
}
+ //if we had a match cat the last part
+ if (start != txt.begin())
+ out.append(start, end);
return out;
}
return out;
}