mirror of
https://github.com/anope/anope.git
synced 2026-07-06 19:03:13 +02:00
Use a set instead of a vector for storing memo ignores.
This commit is contained in:
+1
-1
@@ -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;
|
||||
|
||||
@@ -1247,7 +1247,7 @@ private:
|
||||
return false;
|
||||
}
|
||||
|
||||
nc->memos.ignores.push_back(ignored);
|
||||
nc->memos.ignores.insert(ignored);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user