summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-04-09 15:02:10 +0200
committerAttila Molnar <attilamolnar@hush.com>2014-04-09 15:02:10 +0200
commit0c476dd0ca2dc9fc811d760306a541caddf30edb (patch)
tree33ae6f6fc61afbb5406a36fd1256c812ec79f604
parent6dc4436ae48e6cc4b309d3cec609047920916cde (diff)
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
-rw-r--r--include/channels.h3
-rw-r--r--src/channels.cpp7
-rw-r--r--src/coremods/core_channel/cmd_names.cpp2
3 files changed, 4 insertions, 8 deletions
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<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
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<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;
}
}