summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-05 17:22:41 +0000
committerom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-05 17:22:41 +0000
commit46bd3bb94a4278f450a66c05f4b5fb1d55cc9578 (patch)
treeadd77b5e0f1a4bab02c86537af60f6cd2ebe27a0 /src/modules
parent2b28153d13aeef280396fbecd3abb16edb2022b3 (diff)
Hopefully speed this up, it was strlcpy()ing every line even when +c wasnt set, and copying wasn't neccessary anyway
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3463 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_blockcolor.cpp30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/modules/m_blockcolor.cpp b/src/modules/m_blockcolor.cpp
index 701ac692c..de782cf19 100644
--- a/src/modules/m_blockcolor.cpp
+++ b/src/modules/m_blockcolor.cpp
@@ -30,39 +30,34 @@ class ModuleBlockColour : public Module
Server *Srv;
public:
- ModuleBlockColour(Server* Me)
- : Module::Module(Me)
+ ModuleBlockColour(Server* Me) : Module::Module(Me)
{
Srv = Me;
Srv->AddExtendedMode('c',MT_CHANNEL,false,0,0);
}
void Implements(char* List)
- {
- List[I_On005Numeric] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnExtendedMode] = 1;
- }
+ {
+ List[I_On005Numeric] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnExtendedMode] = 1;
+ }
- virtual void On005Numeric(std::string &output)
- {
+ virtual void On005Numeric(std::string &output)
+ {
InsertMode(output,"c",4);
- }
+ }
virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
{
if (target_type == TYPE_CHANNEL)
{
chanrec* c = (chanrec*)dest;
- char ctext[MAXBUF];
- char *ctptr = ctext;
- strlcpy(ctext,text.c_str(),MAXBUF);
-
-
- if (c->IsCustomModeSet('c'))
+
+ if(c->IsCustomModeSet('c'))
{
- /* Instead of using strchr() here, do our own loop. Hopefully faster. --w00t */
- while (ctptr && *ctptr)
+ /* Replace a strlcpy(), which ran even when +c wasn't set, with this (no copies at all) -- Om */
+ for(unsigned int i = 0; i < text.length(); i++)
{
- switch (*ctptr++)
+ switch (text[i])
{
case 2:
case 3:
@@ -133,4 +128,3 @@ extern "C" void * init_module( void )
{
return new ModuleBlockColourFactory;
}
-