summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2025-03-19 10:12:02 +0000
committerSadie Powell <sadie@witchery.services>2025-03-19 10:12:02 +0000
commite86fa67e38788982993e40210aa4a24db890dbbd (patch)
treedf6e7b9a827cbd9093d8b74e130d16e25251da30
parent1fc26420345901d2963657fd765fd24af4bce4cd (diff)
Use a set instead of a vector for storing memo ignores.
-rw-r--r--include/memo.h2
-rw-r--r--modules/database/db_atheme.cpp2
-rw-r--r--modules/memoserv/ms_ignore.cpp12
-rw-r--r--src/nickcore.cpp2
-rw-r--r--src/regchannel.cpp2
5 files changed, 6 insertions, 14 deletions
diff --git a/include/memo.h b/include/memo.h
index 4d5a43af2..cff76dcd3 100644
--- a/include/memo.h
+++ b/include/memo.h
@@ -46,7 +46,7 @@ struct CoreExport MemoInfo final
{
int16_t memomax = 0;
Serialize::Checker<std::vector<Memo *> > memos;
- std::vector<Anope::string> ignores;
+ std::set<Anope::string, ci::less> ignores;
MemoInfo();
Memo *GetMemo(unsigned index) const;
diff --git a/modules/database/db_atheme.cpp b/modules/database/db_atheme.cpp
index 860e81853..133d82c93 100644
--- a/modules/database/db_atheme.cpp
+++ b/modules/database/db_atheme.cpp
@@ -1247,7 +1247,7 @@ private:
return false;
}
- nc->memos.ignores.push_back(ignored);
+ nc->memos.ignores.insert(ignored);
return true;
}
diff --git a/modules/memoserv/ms_ignore.cpp b/modules/memoserv/ms_ignore.cpp
index 1a3a054d5..6b50d90bc 100644
--- a/modules/memoserv/ms_ignore.cpp
+++ b/modules/memoserv/ms_ignore.cpp
@@ -57,23 +57,15 @@ public:
return;
}
- if (std::find(mi->ignores.begin(), mi->ignores.end(), param.ci_str()) == mi->ignores.end())
- {
- mi->ignores.emplace_back(param.ci_str());
+ if (mi->ignores.insert(param).second)
source.Reply(_("\002%s\002 added to ignore list."), param.c_str());
- }
else
source.Reply(_("\002%s\002 is already on the ignore list."), param.c_str());
}
else if (command.equals_ci("DEL") && !param.empty())
{
- std::vector<Anope::string>::iterator it = std::find(mi->ignores.begin(), mi->ignores.end(), param.ci_str());
-
- if (it != mi->ignores.end())
- {
- mi->ignores.erase(it);
+ if (mi->ignores.erase(param))
source.Reply(_("\002%s\002 removed from the ignore list."), param.c_str());
- }
else
source.Reply(_("\002%s\002 is not on the ignore list."), param.c_str());
}
diff --git a/src/nickcore.cpp b/src/nickcore.cpp
index f971375cb..7ca338aff 100644
--- a/src/nickcore.cpp
+++ b/src/nickcore.cpp
@@ -118,7 +118,7 @@ Serializable *NickCore::Type::Unserialize(Serializable *obj, Serialize::Data &da
spacesepstream sep(buf);
nc->memos.ignores.clear();
while (sep.GetToken(buf))
- nc->memos.ignores.push_back(buf);
+ nc->memos.ignores.insert(buf);
}
Extensible::ExtensibleUnserialize(nc, nc, data);
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index 88adf49b8..376c8d661 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -284,7 +284,7 @@ Serializable *ChannelInfo::Type::Unserialize(Serializable *obj, Serialize::Data
spacesepstream sep(buf);
ci->memos.ignores.clear();
while (sep.GetToken(buf))
- ci->memos.ignores.push_back(buf);
+ ci->memos.ignores.insert(buf);
}
Extensible::ExtensibleUnserialize(ci, ci, data);