From d56539c9abbc2165b29f88c5f62f712497de069b Mon Sep 17 00:00:00 2001 From: w00t Date: Wed, 14 Dec 2005 02:11:32 +0000 Subject: tidystring() anal optimisation git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2388 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/message.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/message.cpp b/src/message.cpp index 8c03e85f2..8adf50793 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -87,32 +87,35 @@ int common_channels(userrec *u, userrec *u2) return 0; } - void tidystring(char* str) { // strips out double spaces before a : parameter - + char temp[MAXBUF]; bool go_again = true; - + if (!str) - { return; - } - - while ((str[0] == ' ') && (strlen(str)>0)) - { + + // pointer voodoo++ --w00t + while ((*str) && (*str == ' ')) str++; - } - + while (go_again) { bool noparse = false; unsigned int t = 0, a = 0; go_again = false; - while (a < strlen(str)) + const int lenofstr = strlen(str); + + /* + * by caching strlen() of str, we theoretically avoid 3 expensive calls each time this loop + * rolls around.. should speed things up a nanosecond or two. ;) + */ + + while (a < lenofstr) { - if ((a