summaryrefslogtreecommitdiff
path: root/icespider/fcgi
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2019-11-12 16:16:37 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2019-11-12 16:16:37 +0000
commit6bdc9fe7ff98f6d76fc9f959b8c39e993a064216 (patch)
treed7d444fd5c0b3385ca18a85b65ffef7835c0e268 /icespider/fcgi
parentModernize build (diff)
downloadicespider-6bdc9fe7ff98f6d76fc9f959b8c39e993a064216.tar.bz2
icespider-6bdc9fe7ff98f6d76fc9f959b8c39e993a064216.tar.xz
icespider-6bdc9fe7ff98f6d76fc9f959b8c39e993a064216.zip
Performance fixesicespider-0.6.2
Diffstat (limited to 'icespider/fcgi')
-rw-r--r--icespider/fcgi/cgiRequestBase.cpp32
-rw-r--r--icespider/fcgi/cgiRequestBase.h5
2 files changed, 12 insertions, 25 deletions
diff --git a/icespider/fcgi/cgiRequestBase.cpp b/icespider/fcgi/cgiRequestBase.cpp
index ab4d5e8..b6d5a77 100644
--- a/icespider/fcgi/cgiRequestBase.cpp
+++ b/icespider/fcgi/cgiRequestBase.cpp
@@ -15,9 +15,10 @@ using namespace std::literals;
#define CGI_CONST(NAME) static const std::string_view NAME(#NAME)
namespace IceSpider {
- static const std::string_view amp("&");
- static const std::string_view semi("; ");
- static const std::string_view HEADER_PREFIX("HTTP_");
+ static const auto slash_pred = boost::algorithm::is_any_of("/");
+ constexpr std::string_view amp("&");
+ constexpr std::string_view semi("; ");
+ constexpr std::string_view HEADER_PREFIX("HTTP_");
CGI_CONST(REDIRECT_URL);
CGI_CONST(SCRIPT_NAME);
CGI_CONST(QUERY_STRING);
@@ -46,43 +47,32 @@ namespace IceSpider {
mapVars(const std::string_view & vn, const in & envmap, out & map, const std::string_view & sp) {
auto qs = envmap.find(vn);
if (qs != envmap.end()) {
- XWwwFormUrlEncoded::iterateVars(qs->second, [&map](const auto && k, const auto && v) {
+ XWwwFormUrlEncoded::iterateVars(qs->second, [&map](auto && k, auto && v) {
map.emplace(std::move(k), std::move(v));
}, sp);
}
}
- template<typename Ex, typename Map>
- const std::string_view &
- findFirstOrElse(const Map &)
- {
- throw Ex();
- }
-
template<typename Ex, typename Map, typename ... Ks>
const std::string_view &
findFirstOrElse(const Map & map, const std::string_view & k, const Ks & ... ks)
{
- auto i = map.find(k);
- if (i == map.end()) {
+ if (const auto i = map.find(k); i != map.end()) {
+ return i->second;
+ }
+ if constexpr (sizeof...(ks)) {
return findFirstOrElse<Ex>(map, ks...);
}
- return i->second;
- }
-
- bool CgiRequestBase::ciLess::operator() (const std::string_view & s1, const std::string_view & s2) const
- {
- return lexicographical_compare(s1, s2, ba::is_iless());
+ throw Ex();
}
void
CgiRequestBase::initialize()
{
- namespace ba = boost::algorithm;
if (auto path = findFirstOrElse<Http400_BadRequest>(envmap, REDIRECT_URL, SCRIPT_NAME).substr(1);
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
!path.empty()) {
- ba::split(pathElements, path, ba::is_any_of("/"), ba::token_compress_off);
+ ba::split(pathElements, path, slash_pred, ba::token_compress_off);
}
mapVars(QUERY_STRING, envmap, qsmap, amp);
diff --git a/icespider/fcgi/cgiRequestBase.h b/icespider/fcgi/cgiRequestBase.h
index fca2e41..88bc473 100644
--- a/icespider/fcgi/cgiRequestBase.h
+++ b/icespider/fcgi/cgiRequestBase.h
@@ -14,11 +14,8 @@ namespace IceSpider {
void initialize();
public:
- struct ciLess {
- bool operator()(const std::string_view & s1, const std::string_view & s2) const;
- };
typedef std::map<std::string_view, const std::string_view> VarMap;
- typedef std::map<std::string_view, const std::string_view, ciLess> HdrMap;
+ typedef std::map<std::string_view, const std::string_view, Slicer::case_less> HdrMap;
const PathElements & getRequestPath() const override;
PathElements & getRequestPath() override;