From: Attila Molnar Date: Wed, 9 Apr 2014 13:02:10 +0000 (+0200) Subject: Avoid double Membership lookup in Channel::UserList() X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=0c476dd0ca2dc9fc811d760306a541caddf30edb;p=user%2Fhenk%2Fcode%2Finspircd.git Avoid double Membership lookup in Channel::UserList() The user is always inside if UserList() is called from ForceJoin() and the HasUser() result obtained in the /NAMES handler can be reused --- diff --git a/include/channels.h b/include/channels.h index 628f34f9f..736ca2e98 100644 --- a/include/channels.h +++ b/include/channels.h @@ -289,8 +289,9 @@ class CoreExport Channel : public Extensible, public InviteBase /** Spool the NAMES list for this channel to the given user * @param user The user to spool the NAMES list to + * @param isinside If true, the user is inside the channel, if not then false */ - void UserList(User *user); + void UserList(User* user, bool isinside = true); /** Get the value of a users prefix on this channel. * @param user The user to look up diff --git a/src/channels.cpp b/src/channels.cpp index 485ffd4c9..089b6927e 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -626,7 +626,7 @@ const char* Channel::ChanModes(bool showkey) /* compile a userlist of a channel into a string, each nick seperated by * spaces and op, voice etc status shown as @ and +, and send it to 'user' */ -void Channel::UserList(User *user) +void Channel::UserList(User* user, bool has_user) { bool has_privs = user->HasPrivPermission("channels/auspex"); std::string list; @@ -635,11 +635,6 @@ void Channel::UserList(User *user) list.append(this->name).append(" :"); std::string::size_type pos = list.size(); - /* Improvement by Brain - this doesnt change in value, so why was it inside - * the loop? - */ - bool has_user = this->HasUser(user); - const size_t maxlen = ServerInstance->Config->Limits.MaxLine - 10 - ServerInstance->Config->ServerName.size(); std::string prefixlist; std::string nick; diff --git a/src/coremods/core_channel/cmd_names.cpp b/src/coremods/core_channel/cmd_names.cpp index 558ad8407..20faae774 100644 --- a/src/coremods/core_channel/cmd_names.cpp +++ b/src/coremods/core_channel/cmd_names.cpp @@ -54,7 +54,7 @@ CmdResult CommandNames::Handle (const std::vector& parameters, User bool has_user = c->HasUser(user); if ((!c->IsModeSet(secretmode)) || (has_user) || (user->HasPrivPermission("channels/auspex"))) { - c->UserList(user); + c->UserList(user, has_user); return CMD_SUCCESS; } }