From 7cec53e24819e6b67082edd37e7f42ca6ff115dd Mon Sep 17 00:00:00 2001 From: JCW Date: Fri, 29 Aug 2025 22:31:43 +0100 Subject: [PATCH] Optimise Signed-off-by: JCW --- include/xrpl/beast/utility/Journal.h | 12 ++++-------- src/libxrpl/beast/utility/beast_Journal.cpp | 16 ++++------------ 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/include/xrpl/beast/utility/Journal.h b/include/xrpl/beast/utility/Journal.h index d3650c4ee9..f3e216e36b 100644 --- a/include/xrpl/beast/utility/Journal.h +++ b/include/xrpl/beast/utility/Journal.h @@ -147,8 +147,8 @@ public: void setModuleName(std::string const& name); - [[nodiscard]] static JsonLogAttributes - combine(AttributeFields const& a, AttributeFields const& b); + void + combine(AttributeFields const& from); AttributeFields& contextValues() @@ -461,9 +461,7 @@ public: if (other.m_attributes.has_value()) { if (m_attributes.has_value()) - m_attributes = JsonLogAttributes::combine( - other.m_attributes->contextValues_, - m_attributes->contextValues_); + m_attributes->combine(other.m_attributes->contextValues_); else m_attributes = other.m_attributes; } @@ -591,9 +589,7 @@ public: { globalLogAttributes_ = JsonLogAttributes{}; } - globalLogAttributes_ = JsonLogAttributes::combine( - globalLogAttributes_->contextValues(), - globalLogAttributes.contextValues()); + globalLogAttributes_->combine(globalLogAttributes.contextValues()); } }; diff --git a/src/libxrpl/beast/utility/beast_Journal.cpp b/src/libxrpl/beast/utility/beast_Journal.cpp index 39ad716ac7..75c7ac9511 100644 --- a/src/libxrpl/beast/utility/beast_Journal.cpp +++ b/src/libxrpl/beast/utility/beast_Journal.cpp @@ -164,21 +164,13 @@ Journal::JsonLogAttributes::setModuleName(std::string const& name) contextValues_.as_object()["Module"] = name; } -Journal::JsonLogAttributes -Journal::JsonLogAttributes::combine( - AttributeFields const& a, - AttributeFields const& b) +void +Journal::JsonLogAttributes::combine(AttributeFields const& from) { - JsonLogAttributes result; - - result.contextValues_ = a; - - for (auto& [key, value] : b.as_object()) + for (auto& [key, value] : from.as_object()) { - result.contextValues_.as_object()[key] = value; + contextValues_.as_object()[key] = value; } - - return result; } void