From ff6f4149d99dbc632f171d8ceac6f175989c0bfc Mon Sep 17 00:00:00 2001 From: w00t Date: Fri, 23 Dec 2005 07:53:11 +0000 Subject: (Probably) major speed improvements, nuked a hell of a lot of strlen()s. Added a note questioning why we're using OnServerRaw() for this. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2641 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_antibottler.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/modules/m_antibottler.cpp b/src/modules/m_antibottler.cpp index 8b11c80c5..fd91183dc 100644 --- a/src/modules/m_antibottler.cpp +++ b/src/modules/m_antibottler.cpp @@ -42,7 +42,7 @@ class ModuleAntiBottler : public Module return Version(1,0,0,1,VF_VENDOR); } - + /* XXX - OnServerRaw? Wouldn't it be easier to use an OnUserConnect, or something? --w00t */ virtual void OnServerRaw(std::string &raw, bool inbound, userrec* user) { if (inbound) @@ -63,16 +63,24 @@ class ModuleAntiBottler : public Module } } // Bug Fix (#14) -- FCS - if (!strlen(data)) return; + + if (!(data) || !(*data)) + return; + + /* + * slight efficiency fix: strtok() just returns NULL if it has no more + * tokens to return. Plus strlen's here really could have been replaced + * with above pointer voodoo :-). --w00t + */ strtok(data," "); - if (!strlen(data)) return; char *ident = strtok(NULL," "); - if (!strlen(data)) return; char *local = strtok(NULL," "); - if (!strlen(data)) return; char *remote = strtok(NULL," :"); - if (!strlen(data)) return; char *gecos = strtok(NULL,"\r\n"); + + if (!ident || !local || !remote || !gecos) + return; + for (unsigned int j = 0; j < strlen(remote); j++) { if (((remote[j] < '0') || (remote[j] > '9')) && (remote[j] != '.')) -- cgit v1.2.3