This is an automated email from the ASF dual-hosted git repository. swebb2066 pushed a commit to branch optimise_async_buffer in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit 46f87eaac68713c2b895e29f50ea93e107dd270b Author: Stephen Webb <[email protected]> AuthorDate: Fri Feb 13 12:16:57 2026 +1100 Reduce overhead of AsyncBuffer::operator<< --- src/main/cpp/asyncbuffer.cpp | 22 +++++++++++----------- src/main/include/log4cxx/helpers/asyncbuffer.h | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/cpp/asyncbuffer.cpp b/src/main/cpp/asyncbuffer.cpp index a0b0711f..39cb4fb5 100644 --- a/src/main/cpp/asyncbuffer.cpp +++ b/src/main/cpp/asyncbuffer.cpp @@ -36,8 +36,8 @@ struct AsyncBuffer::Private #endif // !(defined(__cpp_concepts) && 202002 <= __cpp_concepts && LOG4CXX_WCHAR_T_API) std::vector<value_t> data; - Private(const value_t& f) - : data{ f } + Private(value_t&& f) + : data{ std::move(f) } {} #if LOG4CXX_ASYNC_BUFFER_SUPPORTS_FMT @@ -210,36 +210,36 @@ void AsyncBuffer::clear() /** * Append \c function to this buffer. */ -void AsyncBuffer::append(const MessageBufferAppender& f) +void AsyncBuffer::append(MessageBufferAppender&& f) { if (!m_priv) - m_priv = std::make_unique<Private>(f); + m_priv = std::make_unique<Private>(std::move(f)); else - m_priv->data.push_back(f); + m_priv->data.push_back(std::move(f)); } #if LOG4CXX_WCHAR_T_API /** * Append \c function to this buffer. */ -void AsyncBuffer::append(const WideMessageBufferAppender& f) +void AsyncBuffer::append(WideMessageBufferAppender&& f) { if (!m_priv) - m_priv = std::make_unique<Private>(f); + m_priv = std::make_unique<Private>(std::move(f)); else - m_priv->data.push_back(f); + m_priv->data.push_back(std::move(f)); } #endif // LOG4CXX_WCHAR_T_API #else // !LOG4CXX_CONCEPTS /** * Append \c function to this buffer. */ -void AsyncBuffer::append(const MessageBufferAppender& f) +void AsyncBuffer::append(MessageBufferAppender&& f) { if (!m_priv) - m_priv = std::make_unique<Private>(f); + m_priv = std::make_unique<Private>(std::move(f)); else - m_priv->data.push_back(f); + m_priv->data.push_back(std::move(f)); } #endif // !LOG4CXX_CONCEPTS diff --git a/src/main/include/log4cxx/helpers/asyncbuffer.h b/src/main/include/log4cxx/helpers/asyncbuffer.h index 7beb6894..5639f906 100644 --- a/src/main/include/log4cxx/helpers/asyncbuffer.h +++ b/src/main/include/log4cxx/helpers/asyncbuffer.h @@ -231,7 +231,7 @@ private: /** * Append \c f to this buffer. */ - void append(const MessageBufferAppender& f); + void append(MessageBufferAppender&& f); #if LOG4CXX_WCHAR_T_API using WideMessageBufferAppender = std::function<void(WideMessageBuffer&)>; @@ -239,7 +239,7 @@ private: /** * Append \c f to this buffer. */ - void append(const WideMessageBufferAppender& f); + void append(WideMessageBufferAppender&& f); #endif // LOG4CXX_WCHAR_T_API #else // !LOG4CXX_CONCEPTS using MessageBufferAppender = std::function<void(LogCharMessageBuffer&)>; @@ -247,7 +247,7 @@ private: /** * Append \c f to this buffer. */ - void append(const MessageBufferAppender& f); + void append(MessageBufferAppender&& f); #endif // !LOG4CXX_CONCEPTS #if LOG4CXX_ASYNC_BUFFER_SUPPORTS_FMT
