From e13c73fe5937c95c3733e30ce24c89923fcae944 Mon Sep 17 00:00:00 2001 From: Persson-dev Date: Thu, 6 Feb 2025 22:32:59 +0100 Subject: [PATCH] clean MessageFactory --- include/sp/protocol/MessageFactory.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/sp/protocol/MessageFactory.h b/include/sp/protocol/MessageFactory.h index eaea45b..f2775b9 100644 --- a/include/sp/protocol/MessageFactory.h +++ b/include/sp/protocol/MessageFactory.h @@ -19,8 +19,11 @@ struct ArrayFiller {}; template struct ArrayFiller> { - static void ArrayAppend(details::ArrayType& array) { + static ArrayType ArrayCreate() { + ArrayType array; + array.reserve(sizeof...(TMessages)); ArrayFiller::ArrayAppend(array); + return array; } }; @@ -46,9 +49,7 @@ class MessageFactory { public: using IdType = typename TBase::MsgIdType; - MessageFactory() { - details::ArrayFiller::ArrayAppend(m_Factory); - } + MessageFactory() : m_Factory(details::ArrayFiller::ArrayCreate()) {} std::unique_ptr CreateMessage(IdType id) { if (id >= m_Factory.size())