]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Avoid double Membership lookup in Channel::UserList()
authorAttila Molnar <attilamolnar@hush.com>
Wed, 9 Apr 2014 13:02:10 +0000 (15:02 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Wed, 9 Apr 2014 13:02:10 +0000 (15:02 +0200)
The user is always inside if UserList() is called from ForceJoin() and the HasUser() result obtained in the /NAMES handler can be reused

include/channels.h
src/channels.cpp
src/coremods/core_channel/cmd_names.cpp

index 628f34f9f995a46bb6dee2b81092f77cbf4c9957..736ca2e98f602e36370712900e9f52970eee621b 100644 (file)
@@ -289,8 +289,9 @@ class CoreExport Channel : public Extensible, public InviteBase<Channel>
 
        /** 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
index 485ffd4c914bf90f964242c3eb8a03eb7f400af3..089b6927e0e12e0830115b89f3fc0f3f3ef85a84 100644 (file)
@@ -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;
index 558ad84078ae950faebd82bffd58e2120a73f572..20faae7744bcd73d488cd35e23bd8841cea1abba 100644 (file)
@@ -54,7 +54,7 @@ CmdResult CommandNames::Handle (const std::vector<std::string>& 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;
                }
        }