aboutsummaryrefslogtreecommitdiff
path: root/modules/silence.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/silence.cpp')
-rw-r--r--modules/silence.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/modules/silence.cpp b/modules/silence.cpp
index 9e1f2ab44..2b0aa46a2 100644
--- a/modules/silence.cpp
+++ b/modules/silence.cpp
@@ -4,7 +4,7 @@
* Copyright (C) 2021 Dominic Hamon
* Copyright (C) 2019 linuxdaemon <linuxdaemon.irc@gmail.com>
* Copyright (C) 2019 iwalkalone <iwalkalone69@gmail.com>
- * Copyright (C) 2018-2024 Sadie Powell <sadie@witchery.services>
+ * Copyright (C) 2018-2025 Sadie Powell <sadie@witchery.services>
* Copyright (C) 2015 Renegade334 <contact.caaeed4f@renegade334.me.uk>
* Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
* Copyright (C) 2012 Attila Molnar <attilamolnar@hush.com>
@@ -223,7 +223,7 @@ public:
// Remove the old list and create a new one.
Unset(user, false);
- auto* list = new SilenceList();
+ SilenceList* list = nullptr;
irc::spacesepstream ts(value);
while (!ts.StreamEnd())
@@ -259,32 +259,28 @@ public:
}
// Store the silence entry.
+ if (!list)
+ list = new SilenceList();
list->emplace(flags, mask);
}
- // 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, false);
+ if (list)
+ Set(user, list, false);
}
std::string ToInternal(const Extensible* container, void* item) const noexcept override
{
- SilenceList* list = static_cast<SilenceList*>(item);
+ auto* list = static_cast<SilenceList*>(item);
std::string buf;
- for (SilenceList::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->mask);
+ buf.append(entry.mask);
buf.push_back(' ');
- buf.append(SilenceEntry::BitsToFlags(iter->flags));
+ buf.append(SilenceEntry::BitsToFlags(entry.flags));
}
return buf;
}