Optionally skip copying into connection arena for appendMessage

This commit is contained in:
2025-08-19 13:44:16 -04:00
parent 455ab749a6
commit 0d688d9ce9
2 changed files with 10 additions and 6 deletions

View File

@@ -27,10 +27,14 @@ Connection::~Connection() {
}
}
void Connection::appendMessage(std::string_view s) {
char *arena_str = arena_.allocate<char>(s.size());
std::memcpy(arena_str, s.data(), s.size());
messages_.emplace_back(arena_str, s.size());
void Connection::appendMessage(std::string_view s, bool copyToArena) {
if (copyToArena) {
char *arena_str = arena_.allocate<char>(s.size());
std::memcpy(arena_str, s.data(), s.size());
messages_.emplace_back(arena_str, s.size());
} else {
messages_.push_back(s);
}
}
std::string_view Connection::readBytes(size_t /*max_request_size*/,
@@ -131,4 +135,4 @@ void Connection::tsan_release() {
#if __has_feature(thread_sanitizer)
tsan_sync_.store(0, std::memory_order_release);
#endif
}
}