diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-07-29 14:16:09 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-07-29 14:16:09 +0100 |
commit | dfbf7c6f30ce1b01cff23c364b7951b7e7f2e483 (patch) | |
tree | 0dffc674c92be8418279fa6580b47b60f5faf7b0 | |
parent | Centralise lots of value conversion functions (diff) | |
download | icespider-dfbf7c6f30ce1b01cff23c364b7951b7e7f2e483.tar.bz2 icespider-dfbf7c6f30ce1b01cff23c364b7951b7e7f2e483.tar.xz icespider-dfbf7c6f30ce1b01cff23c364b7951b7e7f2e483.zip |
getURLParam needn't go through the optional helpers
-rw-r--r-- | icespider/core/ihttpRequest.cpp | 2 | ||||
-rw-r--r-- | icespider/core/ihttpRequest.h | 4 | ||||
-rw-r--r-- | icespider/unittests/testPerf.cpp | 9 |
3 files changed, 12 insertions, 3 deletions
diff --git a/icespider/core/ihttpRequest.cpp b/icespider/core/ihttpRequest.cpp index 64a891d..461fc9e 100644 --- a/icespider/core/ihttpRequest.cpp +++ b/icespider/core/ihttpRequest.cpp @@ -132,7 +132,7 @@ namespace IceSpider { } } - OptionalString + std::string_view IHttpRequest::getURLParamStr(const unsigned int idx) const { auto & url = getRequestPath(); diff --git a/icespider/core/ihttpRequest.h b/icespider/core/ihttpRequest.h index 6876c2b..2b4ac02 100644 --- a/icespider/core/ihttpRequest.h +++ b/icespider/core/ihttpRequest.h @@ -46,7 +46,7 @@ namespace IceSpider { [[nodiscard]] virtual PathElements & getRequestPath() = 0; [[nodiscard]] virtual HttpMethod getRequestMethod() const = 0; - [[nodiscard]] OptionalString getURLParamStr(const unsigned int) const; + [[nodiscard]] std::string_view getURLParamStr(const unsigned int) const; [[nodiscard]] virtual OptionalString getQueryStringParamStr(const std::string_view) const = 0; [[nodiscard]] virtual OptionalString getHeaderParamStr(const std::string_view) const = 0; [[nodiscard]] virtual OptionalString getCookieParamStr(const std::string_view) const = 0; @@ -77,7 +77,7 @@ namespace IceSpider { [[nodiscard]] T getURLParam(unsigned int n) const { - return *getFrom<T, unsigned int>(n, &IHttpRequest::getURLParamStr); + return convert<T>(getURLParamStr(n)); } template<typename T> diff --git a/icespider/unittests/testPerf.cpp b/icespider/unittests/testPerf.cpp index 04e5deb..215ea46 100644 --- a/icespider/unittests/testPerf.cpp +++ b/icespider/unittests/testPerf.cpp @@ -102,6 +102,15 @@ BENCHMARK_F(CoreFixture, get_query_string_param_int)(benchmark::State & state) } } +BENCHMARK_F(CoreFixture, get_url_param)(benchmark::State & state) +{ + CharPtrPtrArray env(rootDir / "fixtures/env1"); + TestRequest r(this, env); + for (auto _ : state) { + benchmark::DoNotOptimize(r.getURLParam<std::string_view>(0)); + } +} + BENCHMARK_F(CoreFixture, get_cookie_param)(benchmark::State & state) { CharPtrPtrArray env(rootDir / "fixtures/env1"); |