summaryrefslogtreecommitdiff
path: root/src/sessions.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-11-13 15:20:56 -0500
committerAdam <Adam@anope.org>2010-12-12 19:33:58 -0500
commitc792c7f62df41c48d0d813a809e5415cbefa38b2 (patch)
treef7778d83dba9092bdd04ec6cf568c427e34e3218 /src/sessions.cpp
parente5127603642d3f04a21480697bdf59517775fd8b (diff)
Switched the system for storing users, channels, and sesions to a patricia
tree from STL's unordered_map, which was giving horrible performance.
Diffstat (limited to 'src/sessions.cpp')
-rw-r--r--src/sessions.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/sessions.cpp b/src/sessions.cpp
index f13683050..aa5d1c29b 100644
--- a/src/sessions.cpp
+++ b/src/sessions.cpp
@@ -45,7 +45,7 @@
/*************************************************************************/
-session_map SessionList;
+patricia_tree<Session> SessionList;
std::vector<Exception *> exceptions;
@@ -58,9 +58,9 @@ void get_session_stats(long &count, long &mem)
count = SessionList.size();
mem = sizeof(Session) * SessionList.size();
- for (session_map::const_iterator it = SessionList.begin(), it_end = SessionList.end(); it != it_end; ++it)
+ for (patricia_tree<Session>::const_iterator it = SessionList.begin(), it_end = SessionList.end(); it != it_end; ++it)
{
- Session *session = it->second;
+ Session *session = *it;
mem += session->host.length() + 1;
}
@@ -89,11 +89,7 @@ void get_exception_stats(long &count, long &mem)
Session *findsession(const Anope::string &host)
{
- session_map::const_iterator it = SessionList.find(host);
-
- if (it != SessionList.end())
- return it->second;
- return NULL;
+ return SessionList.find(host);
}
/* Attempt to add a host to the session list. If the addition of the new host
@@ -157,7 +153,7 @@ void add_session(const Anope::string &nick, const Anope::string &host, const Ano
session->count = 1;
session->hits = 0;
- SessionList[session->host] = session;
+ SessionList.insert(session->host, session);
}
}