From 91ca2329986bf3b6611edbc88795d345a4c0353f Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 7 Mar 2006 17:16:55 +0000 Subject: Optimizations git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3517 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/helperfuncs.cpp | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 9080cc6a5..82ee5c148 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -1268,31 +1268,18 @@ void userlist(userrec *user,chanrec *c) int usercount_i(chanrec *c) { - int count = 0; - - if (!c) - { - log(DEFAULT,"*** BUG *** usercount_i was given an invalid parameter"); - return 0; - } + if (!c) + return 0; - for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++) - { - if (has_channel(i->second,c)) - { - if (i->second->registered == 7) - { - if ((!has_channel(i->second,c)) && (strchr(i->second->modes,'i'))) - { - /* user is +i, and source not on the channel, does not show - * nick in NAMES list */ - continue; - } - count++; - } - } - } - log(DEBUG,"usercount_i: %s %lu",c->name,(unsigned long)count); + int count = 0; + std::map *ulist= c->GetUsers(); + for (std::map::iterator i = ulist->begin(); i != ulist->end(); i++) + { + char* o = i->second; + userrec* user = (userrec*)o; + if (!strchr(user->modes,'i')) + count++; + } return count; } @@ -1507,9 +1494,10 @@ bool DirValid(char* dirandfile) if( getcwd( otherdir, MAXBUF ) == NULL ) return false; chdir(buffer); - if (strlen(otherdir) >= strlen(work)) + int t = strlen(work); + if (strlen(otherdir) >= t) { - otherdir[strlen(work)] = '\0'; + otherdir[t] = '\0'; if (!strcmp(otherdir,work)) { return true; -- cgit v1.2.3