From a04e586eb51b90d71cb76a2605ca9e194fb21b30 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Wed, 4 Jul 2012 23:02:28 +0200 Subject: m_spanningtree Change TreeServerList to be a set, get rid of a function dedicated to adding entries to it --- src/modules/m_spanningtree/main.cpp | 4 ++-- src/modules/m_spanningtree/postcommand.cpp | 2 +- src/modules/m_spanningtree/protocolinterface.cpp | 2 +- src/modules/m_spanningtree/utils.cpp | 8 +------- src/modules/m_spanningtree/utils.h | 6 +----- 5 files changed, 6 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 9aee4a4ce..ac1d12423 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -498,7 +498,7 @@ void ModuleSpanningTree::OnUserNotice(User* user, void* dest, int target_type, c Utils->GetListOfServersForChannel(c,list,status,exempt_list); for (TreeServerList::iterator i = list.begin(); i != list.end(); i++) { - TreeSocket* Sock = i->second->GetSocket(); + TreeSocket* Sock = (*i)->GetSocket(); if (Sock) Sock->WriteLine(":"+std::string(user->uuid)+" NOTICE "+cname+" :"+text); } @@ -551,7 +551,7 @@ void ModuleSpanningTree::OnUserMessage(User* user, void* dest, int target_type, Utils->GetListOfServersForChannel(c,list,status,exempt_list); for (TreeServerList::iterator i = list.begin(); i != list.end(); i++) { - TreeSocket* Sock = i->second->GetSocket(); + TreeSocket* Sock = (*i)->GetSocket(); if (Sock) Sock->WriteLine(":"+std::string(user->uuid)+" PRIVMSG "+cname+" :"+text); } diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp index b91435eee..36f326114 100644 --- a/src/modules/m_spanningtree/postcommand.cpp +++ b/src/modules/m_spanningtree/postcommand.cpp @@ -121,7 +121,7 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, const std::string & data += " " + params[x]; for (TreeServerList::iterator i = list.begin(); i != list.end(); i++) { - TreeSocket* Sock = i->second->GetSocket(); + TreeSocket* Sock = (*i)->GetSocket(); if (origin && origin->GetSocket() == Sock) continue; if (Sock) diff --git a/src/modules/m_spanningtree/protocolinterface.cpp b/src/modules/m_spanningtree/protocolinterface.cpp index 3ab5dae9d..0440823e6 100644 --- a/src/modules/m_spanningtree/protocolinterface.cpp +++ b/src/modules/m_spanningtree/protocolinterface.cpp @@ -145,7 +145,7 @@ void SpanningTreeProtocolInterface::SendChannel(Channel* target, char status, co Utils->GetListOfServersForChannel(target,list,status,exempt_list); for (TreeServerList::iterator i = list.begin(); i != list.end(); i++) { - TreeSocket* Sock = i->second->GetSocket(); + TreeSocket* Sock = (*i)->GetSocket(); if (Sock) Sock->WriteLine(text); } diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index aa8f74d86..7941970da 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -165,12 +165,6 @@ SpanningTreeUtilities::~SpanningTreeUtilities() delete TreeRoot; } -void SpanningTreeUtilities::AddThisServer(TreeServer* server, TreeServerList &list) -{ - if (list.find(server) == list.end()) - list[server] = server; -} - /* returns a list of DIRECT servernames for a specific channel */ void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeServerList &list, char status, const CUList &exempt_list) { @@ -196,7 +190,7 @@ void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeServerLis { TreeServer* best = this->BestRouteTo(i->first->server); if (best) - AddThisServer(best,list); + list.insert(best); } } return; diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h index f3e16230a..fc1d49733 100644 --- a/src/modules/m_spanningtree/utils.h +++ b/src/modules/m_spanningtree/utils.h @@ -37,7 +37,7 @@ class SpanningTreeUtilities; */ typedef std::tr1::unordered_map server_hash; -typedef std::map TreeServerList; +typedef std::set TreeServerList; /** Contains helper functions and variables for this module, * and keeps them out of the global namespace @@ -142,10 +142,6 @@ class SpanningTreeUtilities : public classbase */ void ReadConfiguration(); - /** Add a server to the server list for GetListOfServersForChannel - */ - void AddThisServer(TreeServer* server, TreeServerList &list); - /** Compile a list of servers which contain members of channel c */ void GetListOfServersForChannel(Channel* c, TreeServerList &list, char status, const CUList &exempt_list); -- cgit v1.2.3