diff options
author | Adam <Adam@anope.org> | 2010-11-13 15:20:56 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-12-12 19:33:58 -0500 |
commit | c792c7f62df41c48d0d813a809e5415cbefa38b2 (patch) | |
tree | f7778d83dba9092bdd04ec6cf568c427e34e3218 /src/main.cpp | |
parent | e5127603642d3f04a21480697bdf59517775fd8b (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/main.cpp')
-rw-r--r-- | src/main.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/main.cpp b/src/main.cpp index c87b0a7fc..a18d19a56 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -172,14 +172,16 @@ void do_restart_services() if (quitmsg.empty()) quitmsg = "Restarting"; /* Send a quit for all of our bots */ - for (botinfo_map::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) + for (patricia_tree<BotInfo>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { + BotInfo *bi = *it; + /* Don't use quitmsg here, it may contain information you don't want people to see */ - ircdproto->SendQuit(it->second, "Restarting"); + ircdproto->SendQuit(bi, "Restarting"); /* Erase bots from the user list so they don't get nuked later on */ - UserListByNick.erase(it->second->nick); - if (!it->second->GetUID().empty()) - UserListByUID.erase(it->second->GetUID()); + UserListByNick.erase(bi->nick); + if (!bi->GetUID().empty()) + UserListByUID.erase(bi->GetUID()); } ircdproto->SendSquit(Config->ServerName, quitmsg); SocketEngine->Process(); @@ -212,20 +214,22 @@ static void services_shutdown() if (started && UplinkSock) { /* Send a quit for all of our bots */ - for (botinfo_map::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) + for (patricia_tree<BotInfo>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { + BotInfo *bi = *it; + /* Don't use quitmsg here, it may contain information you don't want people to see */ - ircdproto->SendQuit(it->second, "Shutting down"); + ircdproto->SendQuit(bi, "Shutting down"); /* Erase bots from the user list so they don't get nuked later on */ - UserListByNick.erase(it->second->nick); - if (!it->second->GetUID().empty()) - UserListByUID.erase(it->second->GetUID()); + UserListByNick.erase(bi->nick); + if (!bi->GetUID().empty()) + UserListByUID.erase(bi->GetUID()); } ircdproto->SendSquit(Config->ServerName, quitmsg); while (!UserListByNick.empty()) - delete UserListByNick.begin()->second; + delete UserListByNick.front(); } SocketEngine->Process(); delete UplinkSock; @@ -491,9 +495,9 @@ int main(int ac, char **av, char **envp) FOREACH_MOD(I_OnServerDisconnect, OnServerDisconnect()); /* Clear all of our users, but not our bots */ - for (user_map::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ) + for (patricia_tree<User>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end;) { - User *u = it->second; + User *u = *it; ++it; if (u->server != Me) |