summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2012-10-19 18:42:52 +0200
committerattilamolnar <attilamolnar@hush.com>2012-10-19 18:43:45 +0200
commit0694d647be8e8b2ae07d7460e04392e56e0f34ee (patch)
tree1646000bc80a359950dfa6228a607bddc124005b
parent52ee43ca1d2bebb95f10107de30e5edf0acbb7bc (diff)
m_filter Change exemptfromfilter to be a set
-rw-r--r--src/modules/m_filter.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index 9ad074e3a..234de9727 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -150,7 +150,7 @@ class ModuleFilter : public Module
int erroffset;
int flags;
- std::vector<std::string> exemptfromfilter; // List of channel names excluded from filtering.
+ std::set<std::string> exemptfromfilter; // List of channel names excluded from filtering.
ModuleFilter();
void init();
@@ -301,7 +301,7 @@ ModResult ModuleFilter::OnUserPreNotice(User* user,void* dest,int target_type, s
FilterResult* f = this->FilterMatch(user, text, flags);
if (f)
{
- std::string target = "";
+ std::string target;
if (target_type == TYPE_USER)
{
User* t = (User*)dest;
@@ -310,9 +310,10 @@ ModResult ModuleFilter::OnUserPreNotice(User* user,void* dest,int target_type, s
else if (target_type == TYPE_CHANNEL)
{
Channel* t = (Channel*)dest;
- target = std::string(t->name);
- std::vector<std::string>::iterator i = find(exemptfromfilter.begin(), exemptfromfilter.end(), target);
- if (i != exemptfromfilter.end()) return MOD_RES_PASSTHRU;
+ if (exemptfromfilter.find(t->name) != exemptfromfilter.end())
+ return MOD_RES_PASSTHRU;
+
+ target = t->name;
}
if (f->action == FA_BLOCK)
{
@@ -376,8 +377,9 @@ ModResult ModuleFilter::OnPreCommand(std::string &command, std::vector<std::stri
if (parameters.size() < 2)
return MOD_RES_PASSTHRU;
- std::vector<std::string>::iterator i = find(exemptfromfilter.begin(), exemptfromfilter.end(), parameters[0]);
- if (i != exemptfromfilter.end()) return MOD_RES_PASSTHRU;
+ if (exemptfromfilter.find(parameters[0]) != exemptfromfilter.end())
+ return MOD_RES_PASSTHRU;
+
checkline = parameters[1];
replacepoint = 1;
parting = true;
@@ -443,13 +445,12 @@ ModResult ModuleFilter::OnPreCommand(std::string &command, std::vector<std::stri
void ModuleFilter::OnRehash(User* user)
{
ConfigReader MyConf;
- std::vector<std::string>().swap(exemptfromfilter);
+ exemptfromfilter.clear();
for (int index = 0; index < MyConf.Enumerate("exemptfromfilter"); ++index)
{
std::string chan = MyConf.ReadValue("exemptfromfilter", "channel", index);
- if (!chan.empty()) {
- exemptfromfilter.push_back(chan);
- }
+ if (!chan.empty())
+ exemptfromfilter.insert(chan);
}
std::string newrxengine = "regex/" + MyConf.ReadValue("filteropts", "engine", 0);
if (newrxengine == "regex/")
@@ -687,7 +688,7 @@ ModResult ModuleFilter::OnStats(char symbol, User* user, string_list &results)
{
results.push_back(ServerInstance->Config->ServerName+" 223 "+user->nick+" :"+RegexEngine.GetProvider()+":"+i->freeform+" "+i->flags+" "+FilterActionToString(i->action)+" "+ConvToStr(i->gline_time)+" :"+i->reason);
}
- for (std::vector<std::string>::iterator i = exemptfromfilter.begin(); i != exemptfromfilter.end(); ++i)
+ for (std::set<std::string>::iterator i = exemptfromfilter.begin(); i != exemptfromfilter.end(); ++i)
{
results.push_back(ServerInstance->Config->ServerName+" 223 "+user->nick+" :EXEMPT "+(*i));
}