aboutsummaryrefslogtreecommitdiffstats
path: root/src/inspircd.cpp
diff options
context:
space:
mode:
authorGravatar brain2005-05-09 16:05:07 +0000
committerGravatar brain2005-05-09 16:05:07 +0000
commitd483a20dcb724d28777908c5da0505624729a840 (patch)
tree12ab6a8373ff4776ef00d723a916b8d747a2c73c /src/inspircd.cpp
parentOptimised strlower (much faster, uses a lookup table) (diff)
Optimized userlist() (a lot faster with many users online)
Fixed bug where another users buffer could end up in the buffer of an exiting client before they quit git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1345 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspircd.cpp')
-rw-r--r--src/inspircd.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 36d593fdb..eaedeeb50 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -1499,32 +1499,31 @@ void userlist(userrec *user,chanrec *c)
}
snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
- for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++)
+
+ std::vector<char*> *ulist = c->GetUsers();
+ for (int i = 0; i < ulist->size(); i++)
{
- if (has_channel(i->second,c))
+ char* o = (*ulist)[i];
+ userrec* otheruser = (userrec*)o;
+ if ((!has_channel(user,c)) && (strchr(otheruser->modes,'i')))
{
- if (isnick(i->second->nick))
- {
- 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;
- }
- strlcat(list,cmode(i->second,c),MAXBUF);
- strlcat(list,i->second->nick,MAXBUF);
- strlcat(list," ",MAXBUF);
- if (strlen(list)>(480-NICKMAX))
- {
- /* list overflowed into
- * multiple numerics */
- WriteServ(user->fd,"%s",list);
- snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
- }
- }
+ /* user is +i, and source not on the channel, does not show
+ * nick in NAMES list */
+ continue;
+ }
+ strlcat(list,cmode(otheruser,c),MAXBUF);
+ strlcat(list,otheruser->nick,MAXBUF);
+ strlcat(list," ",MAXBUF);
+ if (strlen(list)>(480-NICKMAX))
+ {
+ /* list overflowed into
+ * multiple numerics */
+ WriteServ(user->fd,"%s",list);
+ snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
}
}
- /* if whats left in the list isnt empty, send it */ if (list[strlen(list)-1] != ':')
+ /* if whats left in the list isnt empty, send it */
+ if (list[strlen(list)-1] != ':')
{
WriteServ(user->fd,"%s",list);
}
@@ -4287,6 +4286,7 @@ int InspIRCd(char** argv, int argc)
int currfd = current->fd;
int floodlines = 0;
// add the data to the users buffer
+ if (result > 0)
if (!current->AddBuffer(data))
{
// AddBuffer returned false, theres too much data in the user's buffer and theyre up to no good.