From 3acd81316431fec7ec53cb40364bb36d6112299f Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 19 Nov 2025 13:24:36 +0000 Subject: Improve dcc allow list serialization. --- src/modules/m_dccallow.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index 14c8e75f3..ac056987f 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -130,7 +130,7 @@ public: // Remove the old list and create a new one. Unset(user, false); - auto* list = new dccallowlist(); + dccallowlist* list = nullptr; irc::spacesepstream ts(value); while (!ts.StreamEnd()) @@ -158,36 +158,32 @@ public: } // Store the DCC allow entry. + if (!list) + list = new dccallowlist(); list->push_back(dccallow); } - // If we have an empty list then don't store it. - if (list->empty()) - { - delete list; - return; - } - // The value was well formed. - Set(user, list); + if (list) + Set(user, list); } std::string ToInternal(const Extensible* container, void* item) const noexcept override { - dccallowlist* list = static_cast(item); + auto* list = static_cast(item); std::string buf; - for (dccallowlist::const_iterator iter = list->begin(); iter != list->end(); ++iter) + for (const auto& entry : *list) { - if (iter != list->begin()) + if (!buf.empty()) buf.push_back(' '); - buf.append(iter->nickname); + buf.append(entry.nickname); buf.push_back(' '); - buf.append(iter->hostmask); + buf.append(entry.hostmask); buf.push_back(' '); - buf.append(ConvToStr(iter->set_on)); + buf.append(ConvToStr(entry.set_on)); buf.push_back(' '); - buf.append(ConvToStr(iter->length)); + buf.append(ConvToStr(entry.length)); } return buf; } -- cgit v1.3.1-10-gc9f91