diff options
| author | Adam <Adam@anope.org> | 2013-02-13 17:42:01 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2013-02-14 01:20:18 -0500 |
| commit | 9e544a6443117861c3d6406e435043f1cf0f7099 (patch) | |
| tree | e7449fb01e377576e8a09f386117d2c251de0596 /src/regchannel.cpp | |
| parent | 225b7c38c127fbc6aac6724012f71c9483a4da77 (diff) | |
Store what channels have references to accounts in NickCore to prevent having to iterate over all channels and then all access entries when nicks expire or from nickserv/alist
Diffstat (limited to 'src/regchannel.cpp')
| -rw-r--r-- | src/regchannel.cpp | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 257eca0ee..2a82590e2 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -82,6 +82,10 @@ AutoKick::~AutoKick() std::vector<AutoKick *>::iterator it = std::find(this->ci->akick->begin(), this->ci->akick->end(), this); if (it != this->ci->akick->end()) this->ci->akick->erase(it); + + const NickAlias *na = NickAlias::Find(this->mask); + if (na != NULL) + na->nc->RemoveChannelReference(this->ci); } } @@ -444,16 +448,9 @@ Serializable* ChannelInfo::Unserialize(Serializable *obj, Serialize::Data &data) ci->ExtensibleUnserialize(data); - if (ci->founder) - --ci->founder->channelcount; - ci->founder = NickCore::Find(sfounder); - if (ci->founder) - ++ci->founder->channelcount; + ci->SetFounder(NickCore::Find(sfounder)); + ci->SetSuccessor(NickCore::Find(ssuccessor)); - ci->successor = NickCore::Find(ssuccessor); - if (ci->founder && *ci->founder == *ci->successor) - ci->successor = NULL; - data["description"] >> ci->desc; data["time_registered"] >> ci->time_registered; data["last_used"] >> ci->last_used; @@ -511,12 +508,18 @@ Serializable* ChannelInfo::Unserialize(Serializable *obj, Serialize::Data &data) void ChannelInfo::SetFounder(NickCore *nc) { if (this->founder) + { --this->founder->channelcount; + this->founder->RemoveChannelReference(this); + } + this->founder = nc; + if (this->founder) + { ++this->founder->channelcount; - if (*this->founder == *this->successor) - this->successor = NULL; + this->founder->AddChannelReference(this); + } } NickCore *ChannelInfo::GetFounder() const @@ -524,6 +527,20 @@ NickCore *ChannelInfo::GetFounder() const return this->founder; } +void ChannelInfo::SetSuccessor(NickCore *nc) +{ + if (this->successor) + this->successor->RemoveChannelReference(this); + this->successor = nc; + if (this->successor) + this->successor->AddChannelReference(this); +} + +NickCore *ChannelInfo::GetSuccessor() const +{ + return this->successor; +} + BotInfo *ChannelInfo::WhoSends() const { if (this && this->bi) @@ -538,6 +555,10 @@ BotInfo *ChannelInfo::WhoSends() const void ChannelInfo::AddAccess(ChanAccess *taccess) { this->access->push_back(taccess); + + const NickAlias *na = NickAlias::Find(taccess->mask); + if (na != NULL) + na->nc->AddChannelReference(this); } ChanAccess *ChannelInfo::GetAccess(unsigned index) const @@ -639,6 +660,8 @@ AutoKick *ChannelInfo::AddAkick(const Anope::string &user, NickCore *akicknc, co this->akick->push_back(autokick); + akicknc->AddChannelReference(this); + return autokick; } |
