From 46bd3bb94a4278f450a66c05f4b5fb1d55cc9578 Mon Sep 17 00:00:00 2001 From: om Date: Sun, 5 Mar 2006 17:22:41 +0000 Subject: 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 --- src/modules/m_blockcolor.cpp | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'src') 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; } - -- cgit v1.2.3