summaryrefslogtreecommitdiff
path: root/src/users.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-04-07 23:46:44 -0500
committerAdam <Adam@anope.org>2013-04-07 23:46:44 -0500
commitfb7fef7a849342ab8463743497e781c5c3e6ae88 (patch)
tree5d230a68b6eed70c7b4f718410dd62fea779654c /src/users.cpp
parent36602224b8b1a11326a224779d16bcb12f0ed532 (diff)
Optimizations of much of the more commonly used code
Diffstat (limited to 'src/users.cpp')
-rw-r--r--src/users.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/users.cpp b/src/users.cpp
index 708a8062c..1355911bf 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -66,7 +66,7 @@ User::User(const Anope::string &snick, const Anope::string &sident, const Anope:
this->nc = NULL;
this->UpdateHost();
- if (sserver) // Our bots are introduced on startup with no server
+ if (sserver && sserver->IsSynced()) // Our bots are introduced on startup with no server
{
++sserver->users;
Log(this, "connect") << (!svhost.empty() ? Anope::string("(") + svhost + ") " : "") << "(" << srealname << ") " << sip << " connected to the network (" << sserver->GetName() << ")";
@@ -76,7 +76,8 @@ User::User(const Anope::string &snick, const Anope::string &sident, const Anope:
{
MaxUserCount = UserListByNick.size();
MaxUserTime = Anope::CurTime;
- Log(this, "maxusers") << "connected - new maximum user count: " << UserListByNick.size();
+ if (sserver && sserver->IsSynced())
+ Log(this, "maxusers") << "connected - new maximum user count: " << UserListByNick.size();
}
bool exempt = false;
@@ -230,7 +231,8 @@ User::~User()
{
if (this->server != NULL)
{
- Log(this, "disconnect") << "(" << this->realname << ") disconnected from the network (" << this->server->GetName() << ")";
+ if (this->server->IsSynced())
+ Log(this, "disconnect") << "(" << this->realname << ") disconnected from the network (" << this->server->GetName() << ")";
--this->server->users;
}
@@ -243,7 +245,7 @@ User::~User()
--OperCount;
while (!this->chans.empty())
- this->chans.front()->chan->DeleteUser(this);
+ this->chans.begin()->second->chan->DeleteUser(this);
UserListByNick.erase(this->nick);
if (!this->uid.empty())
@@ -422,6 +424,9 @@ void User::Identify(NickAlias *na)
void User::Login(NickCore *core)
{
+ if (core == this->nc)
+ return;
+
this->Logout();
this->nc = core;
core->users.push_back(this);
@@ -648,7 +653,8 @@ void User::SetModesInternal(const char *umodes, ...)
vsnprintf(buf, BUFSIZE - 1, umodes, args);
va_end(args);
- Log(this, "mode") << "changes modes to " << buf;
+ if (this->server && this->server->IsSynced())
+ Log(this, "mode") << "changes modes to " << buf;
spacesepstream sep(buf);
sep.GetToken(modebuf);
@@ -718,11 +724,11 @@ Anope::string User::GetModes() const
return m + params;
}
-ChanUserContainer *User::FindChannel(const Channel *c) const
+ChanUserContainer *User::FindChannel(Channel *c) const
{
- for (User::ChanUserList::const_iterator it = this->chans.begin(), it_end = this->chans.end(); it != it_end; ++it)
- if ((*it)->chan == c)
- return *it;
+ User::ChanUserList::const_iterator it = this->chans.find(c);
+ if (it != this->chans.end())
+ return it->second;
return NULL;
}