diff options
Diffstat (limited to 'src/zenhttp/clients/httpclientcommon.h')
| -rw-r--r-- | src/zenhttp/clients/httpclientcommon.h | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/zenhttp/clients/httpclientcommon.h b/src/zenhttp/clients/httpclientcommon.h index 8bb1e9268..5ed946541 100644 --- a/src/zenhttp/clients/httpclientcommon.h +++ b/src/zenhttp/clients/httpclientcommon.h @@ -158,11 +158,18 @@ namespace detail { IncrementalStringMatcher() {} - IncrementalStringMatcher(std::string&& InMatchString) : MatchString(std::move(InMatchString)) {} + IncrementalStringMatcher(std::string&& InMatchString) : MatchString(std::move(InMatchString)) + { + RawMatchString = MatchString.data(); + } - void Init(std::string&& InMatchString) { MatchString = std::move(InMatchString); } + void Init(std::string&& InMatchString) + { + MatchString = std::move(InMatchString); + RawMatchString = MatchString.data(); + } - void Reset() + inline void Reset() { MatchLength = 0; MatchStartOffset = 0; @@ -186,13 +193,13 @@ namespace detail { void Match(uint64_t Offset, char C) { - ZEN_ASSERT_SLOW(!MatchString.empty()); + ZEN_ASSERT_SLOW(RawMatchString != nullptr); if (MatchState == EMatchState::Complete) { Reset(); } - if (C == MatchString[MatchLength]) + if (C == RawMatchString[MatchLength]) { if (MatchLength == 0) { @@ -222,8 +229,9 @@ namespace detail { private: std::string MatchString; + const char* RawMatchString = nullptr; + uint64_t MatchLength = 0; - uint64_t MatchLength = 0; uint64_t MatchStartOffset = 0; }; @@ -233,8 +241,8 @@ namespace detail { std::vector<HttpClient::Response::MultipartBoundary> Boundaries; MultipartBoundaryParser(); - bool Init(const std::string_view ContentTypeHeaderValue); - inline void ParseInput(std::string_view data) { InternalParseInput(data); } + bool Init(const std::string_view ContentTypeHeaderValue); + void ParseInput(std::string_view data); private: IncrementalStringMatcher BoundaryBeginMatcher; @@ -243,8 +251,6 @@ namespace detail { ExtendableStringBuilder<64> BoundaryHeader; uint64_t PayloadOffset = 0; - - void InternalParseInput(std::string_view data); }; std::pair<std::string_view, std::string_view> GetHeaderKeyAndValue(std::string_view HeaderString); |