1
0
mirror of https://github.com/anope/anope.git synced 2026-07-03 11:33:12 +02:00

Switched the system for storing users, channels, and sesions to a patricia

tree from STL's unordered_map, which was giving horrible performance.
This commit is contained in:
Adam
2010-11-13 15:20:56 -05:00
parent e512760364
commit c792c7f62d
23 changed files with 293 additions and 122 deletions
+4 -4
View File
@@ -30,9 +30,9 @@ class CommandBSBotList : public Command
return MOD_CONT;
}
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->second;
BotInfo *bi = *it;
if (!bi->HasFlag(BI_PRIVATE))
{
@@ -47,9 +47,9 @@ class CommandBSBotList : public Command
{
u->SendMessage(BotServ, BOT_BOTLIST_PRIVATE_HEADER);
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->second;
BotInfo *bi = *it;
if (bi->HasFlag(BI_PRIVATE))
{
+2 -2
View File
@@ -207,9 +207,9 @@ class CommandCSAKick : public Command
{
/* Match against all currently online users with equal or
* higher access. - Viper */
for (user_map::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
for (patricia_tree<User>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
{
User *u2 = it->second;
User *u2 = *it;
if ((check_access(u2, ci, CA_FOUNDER) || get_access(u2, ci) >= get_access(u, ci)) && match_usermask(mask, u2))
{
+2 -2
View File
@@ -924,9 +924,9 @@ class DBPlain : public Module
FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, na));
}
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->second;
BotInfo *bi = *it;
db << "BI " << bi->nick << " " << bi->GetIdent() << " " << bi->host << " " << bi->created << " " << bi->chancount << " :" << bi->realname << endl;
if (bi->HasFlag(BI_PRIVATE))
+2 -2
View File
@@ -38,9 +38,9 @@ class CommandOSNOOP : public Command
u->SendMessage(OperServ, OPER_NOOP_SET, server.c_str());
/* Kill all the IRCops of the server */
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; ++it)
{
User *u2 = it->second;
User *u2 = *it;
++it;
if (u2 && is_oper(u2) && Anope::Match(u2->server->GetName(), server, true))
+2 -2
View File
@@ -134,9 +134,9 @@ class CommandOSSession : public Command
u->SendMessage(OperServ, OPER_SESSION_LIST_HEADER, mincount);
u->SendMessage(OperServ, OPER_SESSION_LIST_COLHEAD);
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;
if (session->count >= mincount)
u->SendMessage(OperServ, OPER_SESSION_LIST_FORMAT, session->count, session->host.c_str());
+2 -2
View File
@@ -33,9 +33,9 @@ class CommandOSStaff : public Command
if (na)
{
/* We have to loop all users as some may be logged into an account but not a nick */
for (user_map::iterator uit = UserListByNick.begin(), uit_end = UserListByNick.end(); uit != uit_end; ++uit)
for (patricia_tree<User>::const_iterator uit = UserListByNick.begin(), uit_end = UserListByNick.end(); uit != uit_end; ++uit)
{
User *u2 = uit->second;
User *u2 = *uit;
if (u2->Account() && u2->Account() == na->nc)
{
+4 -4
View File
@@ -50,9 +50,9 @@ class CommandOSUserList : public Command
{
u->SendMessage(OperServ, OPER_USERLIST_HEADER);
for (user_map::const_iterator uit = UserListByNick.begin(), uit_end = UserListByNick.end(); uit != uit_end; ++uit)
for (patricia_tree<User>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
{
User *u2 = uit->second;
User *u2 = *it;
if (!pattern.empty())
{
@@ -60,8 +60,8 @@ class CommandOSUserList : public Command
if (!Anope::Match(mask, pattern))
continue;
if (!Modes.empty())
for (std::list<UserModeName>::iterator it = Modes.begin(), it_end = Modes.end(); it != it_end; ++it)
if (!u2->HasMode(*it))
for (std::list<UserModeName>::iterator mit = Modes.begin(), mit_end = Modes.end(); mit != mit_end; ++mit)
if (!u2->HasMode(*mit))
continue;
}
u->SendMessage(OperServ, OPER_USERLIST_RECORD, u2->nick.c_str(), u2->GetIdent().c_str(), u2->GetDisplayedHost().c_str());
+4 -4
View File
@@ -951,9 +951,9 @@ class DBMySQL : public Module
FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteChannelMetadata, CurChannel));
}
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)
{
CurBot = it->second;
CurBot = *it;
FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteBotMetadata, CurBot));
/* This is for the core bots, bots added by users are already handled by an event */
@@ -1525,8 +1525,8 @@ static void SaveDatabases()
me->RunQuery("TRUNCATE TABLE `anope_bs_core`");
for (botinfo_map::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
me->OnBotCreate(it->second);
for (patricia_tree<BotInfo>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
me->OnBotCreate(*it);
me->RunQuery("TRUNCATE TABLE `anope_cs_info`");
me->RunQuery("TRUNCATE TABLE `anope_bs_badwords`");