diff options
| author | 2010-04-12 18:22:44 -0500 | |
|---|---|---|
| committer | 2010-08-03 17:32:42 -0400 | |
| commit | c120a4e37f8d13f0e2540e2534bd7cc36e1f1950 (patch) | |
| tree | a0415046bbde3c687bf87c2b48b9963bdf9861ab /src/modules/m_censor.cpp | |
| parent | Remove unneeded copy of server name for every remote user (diff) | |
| download | inspircd++-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.cpp | 14 |
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; } } |
