diff options
| author | Dan Engelbrecht <[email protected]> | 2022-04-28 15:32:55 +0200 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-04-28 15:32:55 +0200 |
| commit | db2bee546354a03ca9a94a647161b041b3033491 (patch) | |
| tree | e8e733d73f4f251a8bf3daa043e8e299ed44ed00 /zencore/compactbinarybuilder.cpp | |
| parent | Merge pull request #81 from EpicGames/de/use-bulk-fetch-from-upstream-on-getc... (diff) | |
| download | zen-db2bee546354a03ca9a94a647161b041b3033491.tar.xz zen-db2bee546354a03ca9a94a647161b041b3033491.zip | |
Reduce risk of reallocating backing std::vector in CbWriter::AddBinary
Shard up g_MappingLock in IoBufferExtendedCore::Materialize() to reduce contention during high load
Don't queue upstream cache records if we don't have any upstreams
Diffstat (limited to 'zencore/compactbinarybuilder.cpp')
| -rw-r--r-- | zencore/compactbinarybuilder.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/zencore/compactbinarybuilder.cpp b/zencore/compactbinarybuilder.cpp index 5111504e1..1d2ba45df 100644 --- a/zencore/compactbinarybuilder.cpp +++ b/zencore/compactbinarybuilder.cpp @@ -436,9 +436,10 @@ CbWriter::AddNull() void CbWriter::AddBinary(const void* const Value, const uint64_t Size) { + const size_t SizeByteCount = MeasureVarUInt(Size); + Data.reserve(Data.size() + 1 + SizeByteCount + Size); BeginField(); - const uint32_t SizeByteCount = MeasureVarUInt(Size); - const int64_t SizeOffset = Data.size(); + const size_t SizeOffset = Data.size(); Data.resize(Data.size() + SizeByteCount); WriteVarUInt(Size, Data.data() + SizeOffset); Data.insert(Data.end(), static_cast<const uint8_t*>(Value), static_cast<const uint8_t*>(Value) + Size); |