From: brain Date: Mon, 9 May 2005 15:23:15 +0000 (+0000) Subject: Optimised strlower (much faster, uses a lookup table) X-Git-Tag: v2.0.23~10339 X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=f7e755a60b6cbd245003d60fa0af0c130f1a4d1f;p=user%2Fhenk%2Fcode%2Finspircd.git Optimised strlower (much faster, uses a lookup table) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1344 e03df62e-2008-0410-955e-edbf42e46eb7 --- 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 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");