diff options
| author | Dan Engelbrecht <[email protected]> | 2024-05-30 14:44:34 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-05-30 14:44:34 +0200 |
| commit | 8ce1dc72cce381b2adae256504331f2e8893f262 (patch) | |
| tree | df5ab56ce8cdf0f6664ed611f4cf1fb848718ea6 /src/zencore/include | |
| parent | workspaces review feedback (diff) | |
| download | zen-8ce1dc72cce381b2adae256504331f2e8893f262.tar.xz zen-8ce1dc72cce381b2adae256504331f2e8893f262.zip | |
cache optimizations (#88)
* message formatting optimizations
* bump iostorecompression small value threshold to 1MB
Diffstat (limited to 'src/zencore/include')
| -rw-r--r-- | src/zencore/include/zencore/compactbinarypackage.h | 4 | ||||
| -rw-r--r-- | src/zencore/include/zencore/compositebuffer.h | 13 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/zencore/include/zencore/compactbinarypackage.h b/src/zencore/include/zencore/compactbinarypackage.h index 4a6bca67a..fe4a60a30 100644 --- a/src/zencore/include/zencore/compactbinarypackage.h +++ b/src/zencore/include/zencore/compactbinarypackage.h @@ -77,10 +77,10 @@ public: ZENCORE_API [[nodiscard]] SharedBuffer AsBinary() const; /** Access the attachment as raw binary. Defaults to a null buffer on error. */ - ZENCORE_API [[nodiscard]] CompositeBuffer AsCompositeBinary() const; + ZENCORE_API [[nodiscard]] const CompositeBuffer& AsCompositeBinary() const; /** Access the attachment as compressed binary. Defaults to a null buffer if the attachment is null. */ - ZENCORE_API [[nodiscard]] CompressedBuffer AsCompressedBinary() const; + ZENCORE_API [[nodiscard]] const CompressedBuffer& AsCompressedBinary() const; /** Access the attachment as compact binary. Defaults to a field iterator with no value on error. */ ZENCORE_API [[nodiscard]] CbObject AsObject() const; diff --git a/src/zencore/include/zencore/compositebuffer.h b/src/zencore/include/zencore/compositebuffer.h index 1b6944fc0..b435c5e74 100644 --- a/src/zencore/include/zencore/compositebuffer.h +++ b/src/zencore/include/zencore/compositebuffer.h @@ -123,19 +123,32 @@ private: static inline size_t GetBufferCount(const CompositeBuffer& Buffer) { return Buffer.m_Segments.size(); } inline void AppendBuffers(const CompositeBuffer& Buffer) { + m_Segments.reserve(m_Segments.size() + Buffer.m_Segments.size()); m_Segments.insert(m_Segments.end(), begin(Buffer.m_Segments), end(Buffer.m_Segments)); } inline void AppendBuffers(CompositeBuffer&& Buffer) { AppendBuffers(std::move(Buffer.m_Segments)); } static inline size_t GetBufferCount(const SharedBuffer&) { return 1; } + static inline size_t GetBufferCount(const IoBuffer&) { return 1; } inline void AppendBuffers(const SharedBuffer& Buffer) { m_Segments.push_back(Buffer); } inline void AppendBuffers(SharedBuffer&& Buffer) { m_Segments.push_back(std::move(Buffer)); } + inline void AppendBuffers(IoBuffer&& Buffer) { m_Segments.push_back(SharedBuffer(std::move(Buffer))); } static inline size_t GetBufferCount(std::vector<SharedBuffer>&& Container) { return Container.size(); } + static inline size_t GetBufferCount(std::vector<IoBuffer>&& Container) { return Container.size(); } inline void AppendBuffers(std::vector<SharedBuffer>&& Container) { + m_Segments.reserve(m_Segments.size() + Container.size()); m_Segments.insert(m_Segments.end(), std::make_move_iterator(Container.begin()), std::make_move_iterator(Container.end())); } + inline void AppendBuffers(std::vector<IoBuffer>&& Container) + { + m_Segments.reserve(m_Segments.size() + Container.size()); + for (IoBuffer& Buffer : Container) + { + m_Segments.emplace_back(SharedBuffer(std::move(Buffer))); + } + } private: std::vector<SharedBuffer> m_Segments; |