From c120a4e37f8d13f0e2540e2534bd7cc36e1f1950 Mon Sep 17 00:00:00 2001 From: Daniel De Graaf Date: Mon, 12 Apr 2010 18:22:44 -0500 Subject: 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(). --- src/modules/m_censor.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/modules/m_censor.cpp') 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 -typedef std::map censor_t; +typedef std::map 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; } } -- cgit v1.3.1-10-gc9f91