Reuse buffers to send network data
This commit is contained in:
@@ -107,6 +107,13 @@ class serialization_packet
|
||||
public:
|
||||
serialization_packet() = default;
|
||||
|
||||
void clear()
|
||||
{
|
||||
buffer.clear();
|
||||
spans.clear();
|
||||
spans.push_back({size_t(0)});
|
||||
}
|
||||
|
||||
void write(const void * data, size_t size)
|
||||
{
|
||||
size_t index = buffer.size();
|
||||
|
||||
@@ -196,7 +196,8 @@ public:
|
||||
template <typename T>
|
||||
void send(T && data)
|
||||
{
|
||||
serialization_packet p;
|
||||
thread_local serialization_packet p;
|
||||
p.clear();
|
||||
uint8_t index = details::Index<std::decay_t<T>, std::tuple<VariantTypes...>>::value;
|
||||
p.serialize(index);
|
||||
p.serialize(std::forward<T>(data));
|
||||
|
||||
Reference in New Issue
Block a user