aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/zenhttp/clients/httpclientcommon.cpp12
-rw-r--r--src/zenhttp/clients/httpclientcommon.h26
2 files changed, 23 insertions, 15 deletions
diff --git a/src/zenhttp/clients/httpclientcommon.cpp b/src/zenhttp/clients/httpclientcommon.cpp
index 312ca16d2..c016e1c3c 100644
--- a/src/zenhttp/clients/httpclientcommon.cpp
+++ b/src/zenhttp/clients/httpclientcommon.cpp
@@ -425,12 +425,14 @@ namespace detail {
return false;
}
- void MultipartBoundaryParser::InternalParseInput(std::string_view data)
+ void MultipartBoundaryParser::ParseInput(std::string_view data)
{
- size_t ScanPos = 0;
- while (ScanPos < data.length())
+ const char* InputPtr = data.data();
+ size_t InputLength = data.length();
+ size_t ScanPos = 0;
+ while (ScanPos < InputLength)
{
- const char ScanChar = data[ScanPos];
+ const char ScanChar = InputPtr[ScanPos];
if (BoundaryBeginMatcher.MatchState == IncrementalStringMatcher::EMatchState::Complete)
{
if (PayloadOffset + ScanPos < (BoundaryBeginMatcher.GetMatchEndOffset() + BoundaryEndMatcher.GetMatchString().length()))
@@ -504,7 +506,7 @@ namespace detail {
}
ScanPos++;
}
- PayloadOffset += data.length();
+ PayloadOffset += InputLength;
}
std::pair<std::string_view, std::string_view> GetHeaderKeyAndValue(std::string_view HeaderString)
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);