From 136f96068957d1ab71876c6290ecb61a25ad83ba Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 6 Dec 2005 15:19:45 +0000 Subject: Optimized FindServerMask git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2230 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_spanningtree.cpp | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) (limited to 'src/modules/m_spanningtree.cpp') diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index f5da4c51c..7d018918a 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -45,6 +45,12 @@ using namespace std; #define nspace std #endif +/* + * TODO: finish this comment off :p + * The server list in InspIRCd is maintained as two structures + * which hold the data in different ways. + */ + class ModuleSpanningTree; static ModuleSpanningTree* TreeProtocolModule; @@ -374,32 +380,16 @@ TreeServer* BestRouteTo(std::string ServerName) } } -TreeServer* Found; - -/* TODO: These need optimizing to use an iterator of serverlist +/* Find the first server matching a given glob mask */ -void RFindServerMask(TreeServer* Current, std::string ServerName) +TreeServer* FindServerMask(std::string ServerName) { - if (Srv->MatchText(Current->GetName(),ServerName) && (!Found)) - { - Found = Current; - return; - } - if (!Found) + for (server_hash::iterator i = serverlist.begin(); i != serverlist.end(); i++) { - for (unsigned int q = 0; q < Current->ChildCount(); q++) - { - if (!Found) - RFindServerMask(Current->GetChild(q),ServerName); - } + if (Srv->MatchText(i->first,ServerName)) + return i->second; } -} - -TreeServer* FindServerMask(std::string ServerName) -{ - Found = NULL; - RFindServerMask(TreeRoot,ServerName); - return Found; + return NULL; } bool IsServer(std::string ServerName) @@ -800,7 +790,7 @@ class TreeSocket : public InspSocket void SendXLines(TreeServer* Current) { char data[MAXBUF]; - // for zlines and qlines, we should first check if theyre global... + /* Yes, these arent too nice looking, but they get the job done */ for (std::vector::iterator i = zlines.begin(); i != zlines.end(); i++) { snprintf(data,MAXBUF,":%s ADDLINE Z %s %s %lu %lu :%s",Srv->GetServerName().c_str(),i->ipaddr,i->source,(unsigned long)i->set_time,(unsigned long)i->duration,i->reason); @@ -871,7 +861,7 @@ class TreeSocket : public InspSocket void DoBurst(TreeServer* s) { - Srv->SendOpers("*** Bursting to "+s->GetName()+"."); + Srv->SendOpers("*** Bursting to \2"+s->GetName()+"\2."); this->WriteLine("BURST"); // send our version string this->WriteLine(":"+Srv->GetServerName()+" VERSION :"+GetVersionString()); @@ -883,6 +873,7 @@ class TreeSocket : public InspSocket this->SendChannelModes(s); this->SendXLines(s); this->WriteLine("ENDBURST"); + Srv->SendOpers("*** Finished bursting to \2"+s->GetName()+"\2."); } virtual bool OnDataReady() -- cgit v1.2.3