summaryrefslogtreecommitdiff
path: root/src/inspircd.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-05-09 15:23:15 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-05-09 15:23:15 +0000
commitf7e755a60b6cbd245003d60fa0af0c130f1a4d1f (patch)
tree35890227b4a8b26ab0d65135bfed9802b9cfa454 /src/inspircd.cpp
parent79b8813d54326fd4e2643eee46ee2d6b1dea606e (diff)
Optimised strlower (much faster, uses a lookup table)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1344 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspircd.cpp')
-rw-r--r--src/inspircd.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index e31628305..36d593fdb 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -220,6 +220,8 @@ std::vector<userrec*> all_opers;
static char already_sent[65536];
+char lowermap[255];
+
void AddOper(userrec* user)
{
log(DEBUG,"Oper added to optimization list");
@@ -1305,19 +1307,10 @@ void WriteWallOps(userrec *source, bool local_only, char* text, ...)
void strlower(char *n)
{
- if (!n)
+ if (n)
{
- return;
- }
- for (int i = 0; n[i] != 0; i++)
- {
- n[i] = tolower(n[i]);
- if (n[i] == '[')
- n[i] = '{';
- if (n[i] == ']')
- n[i] = '}';
- if (n[i] == '\\')
- n[i] = '|';
+ for (char* t = n; *t; t++)
+ *t = lowermap[*t];
}
}
@@ -2367,6 +2360,17 @@ int main(int argc, char** argv)
}
strlcpy(MyExecutable,argv[0],MAXBUF);
+ // initialize the lowercase mapping table
+ for (int cn = 0; cn < 256; cn++)
+ lowermap[cn] = cn;
+ // lowercase the uppercase chars
+ for (int cn = 65; cn < 91; cn++)
+ lowermap[cn] = tolower(cn);
+ // now replace the specific chars for scandanavian comparison
+ lowermap['['] = '{';
+ lowermap[']'] = '}';
+ lowermap['\\'] = '|';
+
if (InspIRCd(argv,argc) == ERROR)
{
log(DEFAULT,"main: daemon function bailed");