You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by sw...@apache.org on 2026/02/13 01:17:25 UTC
(logging-log4cxx) branch optimise_async_buffer created (now 46f87eaa)
This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a change to branch optimise_async_buffer
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
at 46f87eaa Reduce overhead of AsyncBuffer::operator<<
This branch includes the following new commits:
new 46f87eaa Reduce overhead of AsyncBuffer::operator<<
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(logging-log4cxx) 01/01: Reduce overhead of AsyncBuffer::operator<<
Posted by sw...@apache.org.
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 <sw...@gmail.com>
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