summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-23 07:53:11 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-23 07:53:11 +0000
commitff6f4149d99dbc632f171d8ceac6f175989c0bfc (patch)
treef9606db9aa432cb93f4679c0dce9898a9d7f354a
parent6febf74c3e7ae6e209d4927aa0452ccdf1bad6c0 (diff)
(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
-rw-r--r--src/modules/m_antibottler.cpp20
1 files changed, 14 insertions, 6 deletions
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] != '.'))