aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/m_censor.cpp
diff options
context:
space:
mode:
authorGravatar Daniel De Graaf2010-04-12 18:22:44 -0500
committerGravatar Daniel De Graaf2010-08-03 17:32:42 -0400
commitc120a4e37f8d13f0e2540e2534bd7cc36e1f1950 (patch)
treea0415046bbde3c687bf87c2b48b9963bdf9861ab /src/modules/m_censor.cpp
parentRemove unneeded copy of server name for every remote user (diff)
downloadinspircd++-c120a4e37f8d13f0e2540e2534bd7cc36e1f1950.tar.gz
inspircd++-c120a4e37f8d13f0e2540e2534bd7cc36e1f1950.tar.bz2
inspircd++-c120a4e37f8d13f0e2540e2534bd7cc36e1f1950.zip
Make irc::string faster and less wasteful
Change irc::string from an std::basic_string typedef to a wrapper around an std::string, to avoid unneeded copies in assign().
Diffstat (limited to 'src/modules/m_censor.cpp')
-rw-r--r--src/modules/m_censor.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp
index 399863cf1..5b296b397 100644
--- a/src/modules/m_censor.cpp
+++ b/src/modules/m_censor.cpp
@@ -17,7 +17,7 @@
#include "inspircd.h"
#include <iostream>
-typedef std::map<irc::string,irc::string> censor_t;
+typedef std::map<std::string,std::string> censor_t;
/* $ModDesc: Provides user and channel +G mode */
@@ -85,10 +85,10 @@ class ModuleCensor : public Module
if (!active)
return MOD_RES_PASSTHRU;
- irc::string text2 = text.c_str();
+ std::string text2 = irc::irc_char_traits::remap(text);
for (censor_t::iterator index = censors.begin(); index != censors.end(); index++)
{
- if (text2.find(index->first) != irc::string::npos)
+ if (text2.find(index->first) != std::string::npos)
{
if (index->second.empty())
{
@@ -117,10 +117,12 @@ class ModuleCensor : public Module
ConfigReader MyConf;
censors.clear();
- for (int index = 0; index < MyConf.Enumerate("badword"); index++)
+ ConfigTagList badwords = ServerInstance->Config->ConfTags("badword");
+ for(ConfigIter i = badwords.first; i != badwords.second; ++i)
{
- irc::string pattern = (MyConf.ReadValue("badword","text",index)).c_str();
- irc::string replace = (MyConf.ReadValue("badword","replace",index)).c_str();
+ ConfigTag* tag = i->second;
+ std::string pattern = irc::irc_char_traits::remap(tag->getString("text"));
+ std::string replace = tag->getString("replace");
censors[pattern] = replace;
}
}