aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenhttp')
-rw-r--r--src/zenhttp/httpserver.cpp8
-rw-r--r--src/zenhttp/include/zenhttp/httpserver.h6
-rw-r--r--src/zenhttp/packageformat.cpp34
3 files changed, 24 insertions, 24 deletions
diff --git a/src/zenhttp/httpserver.cpp b/src/zenhttp/httpserver.cpp
index 03117ee6c..31c94eb3b 100644
--- a/src/zenhttp/httpserver.cpp
+++ b/src/zenhttp/httpserver.cpp
@@ -939,9 +939,8 @@ HttpRequestRouter::HandleRequest(zen::HttpServerRequest& Request)
const std::vector<int>& Matchers = Handler.ComponentIndices;
bool IsMatch = true;
- std::vector<std::string_view> CapturedSegments;
-
- CapturedSegments.emplace_back(Uri);
+ RouterRequest.m_CapturedSegments.clear();
+ RouterRequest.m_CapturedSegments.emplace_back(Uri);
for (size_t MatcherOffset = 0; MatcherOffset < Matchers.size(); MatcherOffset++)
{
@@ -991,7 +990,7 @@ HttpRequestRouter::HandleRequest(zen::HttpServerRequest& Request)
if (m_MatcherFunctions[MatcherIndex](Segment))
{
- CapturedSegments.push_back(Segment);
+ RouterRequest.m_CapturedSegments.push_back(Segment);
}
else
{
@@ -1019,7 +1018,6 @@ HttpRequestRouter::HandleRequest(zen::HttpServerRequest& Request)
}
#endif
- RouterRequest.m_CapturedSegments = std::move(CapturedSegments);
Handler.Handler(RouterRequest);
return true; // Route matched
diff --git a/src/zenhttp/include/zenhttp/httpserver.h b/src/zenhttp/include/zenhttp/httpserver.h
index 955b8ed15..bccabf95b 100644
--- a/src/zenhttp/include/zenhttp/httpserver.h
+++ b/src/zenhttp/include/zenhttp/httpserver.h
@@ -17,6 +17,8 @@
#include <zentelemetry/hyperloglog.h>
#include <zentelemetry/stats.h>
+#include <EASTL/fixed_vector.h>
+
#include <filesystem>
#include <functional>
#include <gsl/gsl-lite.hpp>
@@ -405,8 +407,8 @@ private:
HttpRouterRequest(const HttpRouterRequest&) = delete;
HttpRouterRequest& operator=(const HttpRouterRequest&) = delete;
- HttpServerRequest& m_HttpRequest;
- std::vector<std::string_view> m_CapturedSegments;
+ HttpServerRequest& m_HttpRequest;
+ eastl::fixed_vector<std::string_view, 8, /*bEnableOverflow=*/true> m_CapturedSegments;
friend class HttpRequestRouter;
};
diff --git a/src/zenhttp/packageformat.cpp b/src/zenhttp/packageformat.cpp
index 267ce386c..4f001a14f 100644
--- a/src/zenhttp/packageformat.cpp
+++ b/src/zenhttp/packageformat.cpp
@@ -130,7 +130,7 @@ FormatPackageMessageBuffer(const CbPackage& Data, FormatFlags Flags, void* Targe
static void
MarshalLocal(CbAttachmentEntry*& AttachmentInfo,
- const std::string& Path8,
+ std::string_view Path8,
CbAttachmentReferenceHeader& LocalRef,
const IoHash& AttachmentHash,
bool IsCompressed,
@@ -156,7 +156,7 @@ IsLocalRef(tsl::robin_map<void*, std::string>& FileNameMap,
bool DenyPartialLocalReferences,
void* TargetProcessHandle,
CbAttachmentReferenceHeader& LocalRef,
- std::string& Path8)
+ StringBuilderBase& Path8)
{
const SharedBuffer& Segment = AttachmentBinary.GetSegments().front();
IoBufferFileReference Ref;
@@ -172,9 +172,11 @@ IsLocalRef(tsl::robin_map<void*, std::string>& FileNameMap,
return false;
}
+ Path8.Reset();
+
if (auto It = FileNameMap.find(Ref.FileHandle); It != FileNameMap.end())
{
- Path8 = It->second;
+ Path8.Append(It->second);
}
else
{
@@ -193,7 +195,7 @@ IsLocalRef(tsl::robin_map<void*, std::string>& FileNameMap,
if (OK)
{
DuplicatedHandles.push_back((void*)TargetHandle);
- Path8 = fmt::format("{}{}", HandlePrefix, reinterpret_cast<uint64_t>(TargetHandle));
+ fmt::format_to(StringBuilderAppender(Path8), "{}{}", HandlePrefix, reinterpret_cast<uint64_t>(TargetHandle));
UseFilePath = false;
}
}
@@ -205,21 +207,19 @@ IsLocalRef(tsl::robin_map<void*, std::string>& FileNameMap,
#endif // ZEN_PLATFORM_WINDOWS
if (UseFilePath)
{
- ExtendablePathBuilder<256> LocalRefFile;
- std::error_code Ec;
- std::filesystem::path FilePath = PathFromHandle(Ref.FileHandle, Ec);
+ std::error_code Ec;
+ std::filesystem::path FilePath = PathFromHandle(Ref.FileHandle, Ec);
if (Ec)
{
ZEN_WARN("Failed to get path for file handle {} in IsLocalRef check, reason '{}'", Ref.FileHandle, Ec.message());
return false;
}
- LocalRefFile.Append(std::filesystem::absolute(FilePath));
- Path8 = LocalRefFile.ToUtf8();
+ PathToUtf8(std::filesystem::absolute(FilePath), Path8);
}
- FileNameMap.insert_or_assign(Ref.FileHandle, Path8);
+ FileNameMap.insert_or_assign(Ref.FileHandle, Path8.ToString());
}
- LocalRef.AbsolutePathLength = gsl::narrow<uint16_t>(Path8.size());
+ LocalRef.AbsolutePathLength = gsl::narrow<uint16_t>(Path8.Size());
LocalRef.PayloadByteOffset = Ref.FileChunkOffset;
LocalRef.PayloadByteSize = Ref.FileChunkSize;
@@ -302,8 +302,8 @@ FormatPackageMessageInternal(const CbPackage& Data, FormatFlags Flags, void* Tar
bool MarshalByLocalRef = EnumHasAllFlags(Flags, FormatFlags::kAllowLocalReferences) && (Compressed.GetSegments().size() == 1);
bool DenyPartialLocalReferences = EnumHasAllFlags(Flags, FormatFlags::kDenyPartialLocalReferences);
- CbAttachmentReferenceHeader LocalRef;
- std::string Path8;
+ CbAttachmentReferenceHeader LocalRef;
+ ExtendableStringBuilder<128> Path8;
if (MarshalByLocalRef)
{
@@ -321,7 +321,7 @@ FormatPackageMessageInternal(const CbPackage& Data, FormatFlags Flags, void* Tar
const bool IsCompressed = true;
bool IsHandle = false;
#if ZEN_PLATFORM_WINDOWS
- IsHandle = Path8.starts_with(HandlePrefix);
+ IsHandle = Path8.ToView().starts_with(HandlePrefix);
#endif
MarshalLocal(AttachmentInfo, Path8, LocalRef, AttachmentHash, IsCompressed, ResponseBuffers);
ZEN_DEBUG("Marshalled '{}' as file {} of {} bytes", Path8, IsHandle ? "handle" : "path", Compressed.GetSize());
@@ -357,8 +357,8 @@ FormatPackageMessageInternal(const CbPackage& Data, FormatFlags Flags, void* Tar
EnumHasAllFlags(Flags, FormatFlags::kAllowLocalReferences) && (AttachmentBinary.GetSegments().size() == 1);
bool DenyPartialLocalReferences = EnumHasAllFlags(Flags, FormatFlags::kDenyPartialLocalReferences);
- CbAttachmentReferenceHeader LocalRef;
- std::string Path8;
+ CbAttachmentReferenceHeader LocalRef;
+ ExtendableStringBuilder<128> Path8;
if (MarshalByLocalRef)
{
@@ -376,7 +376,7 @@ FormatPackageMessageInternal(const CbPackage& Data, FormatFlags Flags, void* Tar
const bool IsCompressed = false;
bool IsHandle = false;
#if ZEN_PLATFORM_WINDOWS
- IsHandle = Path8.starts_with(HandlePrefix);
+ IsHandle = Path8.ToView().starts_with(HandlePrefix);
#endif
MarshalLocal(AttachmentInfo, Path8, LocalRef, AttachmentHash, IsCompressed, ResponseBuffers);
ZEN_DEBUG("Marshalled '{}' as file {} of {} bytes", Path8, IsHandle ? "handle" : "path", AttachmentBinary.GetSize());