diff options
-rw-r--r-- | include/bots.h | 4 | ||||
-rw-r--r-- | include/patricia.h | 22 | ||||
-rw-r--r-- | include/services.h | 2 | ||||
-rw-r--r-- | include/users.h | 4 | ||||
-rw-r--r-- | modules/core/bs_botlist.cpp | 4 | ||||
-rw-r--r-- | modules/core/cs_akick.cpp | 2 | ||||
-rw-r--r-- | modules/core/db_plain.cpp | 2 | ||||
-rw-r--r-- | modules/core/os_akill.cpp | 2 | ||||
-rw-r--r-- | modules/core/os_noop.cpp | 2 | ||||
-rw-r--r-- | modules/core/os_session.cpp | 2 | ||||
-rw-r--r-- | modules/core/os_snline.cpp | 2 | ||||
-rw-r--r-- | modules/core/os_sqline.cpp | 2 | ||||
-rw-r--r-- | modules/core/os_staff.cpp | 2 | ||||
-rw-r--r-- | modules/core/os_szline.cpp | 2 | ||||
-rw-r--r-- | modules/core/os_userlist.cpp | 2 | ||||
-rw-r--r-- | modules/extra/db_mysql.cpp | 4 | ||||
-rw-r--r-- | src/bots.cpp | 4 | ||||
-rw-r--r-- | src/botserv.cpp | 2 | ||||
-rw-r--r-- | src/init.cpp | 2 | ||||
-rw-r--r-- | src/logger.cpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 6 | ||||
-rw-r--r-- | src/modes.cpp | 2 | ||||
-rw-r--r-- | src/operserv.cpp | 4 | ||||
-rw-r--r-- | src/servers.cpp | 2 | ||||
-rw-r--r-- | src/sessions.cpp | 9 | ||||
-rw-r--r-- | src/users.cpp | 6 |
26 files changed, 47 insertions, 52 deletions
diff --git a/include/bots.h b/include/bots.h index 2c1757a47..bbd40a236 100644 --- a/include/bots.h +++ b/include/bots.h @@ -12,8 +12,8 @@ class BotInfo; -extern CoreExport patricia_tree<BotInfo, std::equal_to<ci::string> > BotListByNick; -extern CoreExport patricia_tree<BotInfo> BotListByUID; +extern CoreExport patricia_tree<BotInfo *, std::equal_to<ci::string> > BotListByNick; +extern CoreExport patricia_tree<BotInfo *> BotListByUID; /** Flags settable on a bot */ diff --git a/include/patricia.h b/include/patricia.h index 73f5c22b9..fc28f4195 100644 --- a/include/patricia.h +++ b/include/patricia.h @@ -8,9 +8,9 @@ template<typename Data> struct patricia_elem { unsigned int bit; patricia_elem<Data> *up, *one, *zero; - typename std::list<Data *>::iterator node; + typename std::list<Data>::iterator node; Anope::string key; - Data *data; + Data data; }; template<typename Data, typename Compare = std::equal_to<Anope::string> > @@ -19,7 +19,7 @@ class patricia_tree Compare comp; patricia_elem<Data> *root; - std::list<Data *> list; + std::list<Data> list; public: @@ -34,8 +34,8 @@ class patricia_tree this->erase(this->root->key); } - typedef typename std::list<Data *>::iterator iterator; - typedef typename std::list<Data *>::const_iterator const_iterator; + typedef typename std::list<Data>::iterator iterator; + typedef typename std::list<Data>::const_iterator const_iterator; inline iterator begin() { return this->list.begin(); } inline iterator end() { return this->list.end(); } @@ -43,13 +43,13 @@ class patricia_tree inline const const_iterator begin() const { return this->list.begin(); } inline const const_iterator end() const { return this->list.end(); } - inline Data *front() { return this->list.front(); } - inline Data *back() { return this->list.back(); } + inline Data front() { return this->list.front(); } + inline Data back() { return this->list.back(); } inline size_t size() const { return this->list.size(); } inline bool empty() const { return this->list.empty(); } - Data *find(const Anope::string &key) + Data find(const Anope::string &key) { size_t keylen = key.length(); patricia_elem<Data> *prev = NULL, *cur = this->root; @@ -72,7 +72,7 @@ class patricia_tree return NULL; } - void insert(const Anope::string &key, Data *data) + void insert(const Anope::string &key, Data data) { if (key.empty() || data == NULL) throw CoreExport; @@ -144,7 +144,7 @@ class patricia_tree newelem->node = this->list.begin(); } - Data *erase(const Anope::string &key) + Data erase(const Anope::string &key) { size_t keylen = key.length(); patricia_elem<Data> *prev = NULL, *cur = this->root; @@ -200,7 +200,7 @@ class patricia_tree this->list.erase(cur->node); - Data *data = cur->data; + Data data = cur->data; delete cur; return data; diff --git a/include/services.h b/include/services.h index 4d2401883..1ebdf608a 100644 --- a/include/services.h +++ b/include/services.h @@ -850,7 +850,7 @@ struct Exception /*************************************************************************/ -extern CoreExport patricia_tree<Session> SessionList; +extern CoreExport patricia_tree<Session *> SessionList; struct Session { diff --git a/include/users.h b/include/users.h index d9f47792f..b6e8ec612 100644 --- a/include/users.h +++ b/include/users.h @@ -8,8 +8,8 @@ #ifndef USERS_H #define USERS_H -extern CoreExport patricia_tree<User, std::equal_to<ci::string> > UserListByNick; -extern CoreExport patricia_tree<User> UserListByUID; +extern CoreExport patricia_tree<User *, std::equal_to<ci::string> > UserListByNick; +extern CoreExport patricia_tree<User *> UserListByUID; class CoreExport ChannelStatus : public Flags<ChannelModeName, CMODE_END * 2> { diff --git a/modules/core/bs_botlist.cpp b/modules/core/bs_botlist.cpp index a8487b03b..2fdf5ec5a 100644 --- a/modules/core/bs_botlist.cpp +++ b/modules/core/bs_botlist.cpp @@ -30,7 +30,7 @@ class CommandBSBotList : public Command return MOD_CONT; } - for (patricia_tree<BotInfo>::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; @@ -47,7 +47,7 @@ class CommandBSBotList : public Command { u->SendMessage(BotServ, BOT_BOTLIST_PRIVATE_HEADER); - for (patricia_tree<BotInfo>::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; diff --git a/modules/core/cs_akick.cpp b/modules/core/cs_akick.cpp index f539952d7..df1171589 100644 --- a/modules/core/cs_akick.cpp +++ b/modules/core/cs_akick.cpp @@ -207,7 +207,7 @@ class CommandCSAKick : public Command { /* Match against all currently online users with equal or * higher access. - Viper */ - for (patricia_tree<User>::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; diff --git a/modules/core/db_plain.cpp b/modules/core/db_plain.cpp index 5db485fc8..78db1aba7 100644 --- a/modules/core/db_plain.cpp +++ b/modules/core/db_plain.cpp @@ -931,7 +931,7 @@ class DBPlain : public Module FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, na)); } - for (patricia_tree<BotInfo>::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; diff --git a/modules/core/os_akill.cpp b/modules/core/os_akill.cpp index fab4a7fee..6473d20ef 100644 --- a/modules/core/os_akill.cpp +++ b/modules/core/os_akill.cpp @@ -174,7 +174,7 @@ class CommandOSAKill : public Command if (user) mask = "*@" + user->host; unsigned int affected = 0; - for (patricia_tree<User>::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) if (Anope::Match((*it)->GetIdent() + "@" + (*it)->host, mask)) ++affected; float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0; diff --git a/modules/core/os_noop.cpp b/modules/core/os_noop.cpp index 56b69fcb7..32b03f63b 100644 --- a/modules/core/os_noop.cpp +++ b/modules/core/os_noop.cpp @@ -38,7 +38,7 @@ class CommandOSNOOP : public Command u->SendMessage(OperServ, OPER_NOOP_SET, server.c_str()); /* Kill all the IRCops of the server */ - for (patricia_tree<User>::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; ++it; diff --git a/modules/core/os_session.cpp b/modules/core/os_session.cpp index fc85c304b..ffaea047f 100644 --- a/modules/core/os_session.cpp +++ b/modules/core/os_session.cpp @@ -134,7 +134,7 @@ class CommandOSSession : public Command u->SendMessage(OperServ, OPER_SESSION_LIST_HEADER, mincount); u->SendMessage(OperServ, OPER_SESSION_LIST_COLHEAD); - for (patricia_tree<Session>::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; diff --git a/modules/core/os_snline.cpp b/modules/core/os_snline.cpp index fb4e84dce..3a28b9427 100644 --- a/modules/core/os_snline.cpp +++ b/modules/core/os_snline.cpp @@ -189,7 +189,7 @@ class CommandOSSNLine : public Command if (mask[masklen - 1] == ' ') mask.erase(masklen - 1); unsigned int affected = 0; - for (patricia_tree<User>::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) if (Anope::Match((*it)->realname, mask)) ++affected; float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0; diff --git a/modules/core/os_sqline.cpp b/modules/core/os_sqline.cpp index 72969aa54..eb90f26d4 100644 --- a/modules/core/os_sqline.cpp +++ b/modules/core/os_sqline.cpp @@ -173,7 +173,7 @@ class CommandOSSQLine : public Command if (user) mask = "*@" + user->host; unsigned int affected = 0; - for (patricia_tree<User>::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) if (Anope::Match((*it)->GetIdent() + "@" + (*it)->host, mask)) ++affected; float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0; diff --git a/modules/core/os_staff.cpp b/modules/core/os_staff.cpp index 6b8b1cb43..136e2ba4f 100644 --- a/modules/core/os_staff.cpp +++ b/modules/core/os_staff.cpp @@ -33,7 +33,7 @@ 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 (patricia_tree<User>::const_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; diff --git a/modules/core/os_szline.cpp b/modules/core/os_szline.cpp index 459dd0f1d..21facdde8 100644 --- a/modules/core/os_szline.cpp +++ b/modules/core/os_szline.cpp @@ -173,7 +173,7 @@ class CommandOSSZLine : public Command if (user && user->ip()) mask = user->ip.addr(); unsigned int affected = 0; - for (patricia_tree<User>::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) if ((*it)->ip() && Anope::Match((*it)->ip.addr(), mask)) ++affected; float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0; diff --git a/modules/core/os_userlist.cpp b/modules/core/os_userlist.cpp index ab1f3adab..436c073d6 100644 --- a/modules/core/os_userlist.cpp +++ b/modules/core/os_userlist.cpp @@ -50,7 +50,7 @@ class CommandOSUserList : public Command { u->SendMessage(OperServ, OPER_USERLIST_HEADER); - for (patricia_tree<User>::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; diff --git a/modules/extra/db_mysql.cpp b/modules/extra/db_mysql.cpp index e49676658..8b90fa59e 100644 --- a/modules/extra/db_mysql.cpp +++ b/modules/extra/db_mysql.cpp @@ -965,7 +965,7 @@ class DBMySQL : public Module FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteChannelMetadata, CurChannel)); } - for (patricia_tree<BotInfo>::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; FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteBotMetadata, CurBot)); @@ -1540,7 +1540,7 @@ static void SaveDatabases() me->RunQuery("TRUNCATE TABLE `anope_bs_core`"); - for (patricia_tree<BotInfo>::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) me->OnBotCreate(*it); me->RunQuery("TRUNCATE TABLE `anope_cs_info`"); diff --git a/src/bots.cpp b/src/bots.cpp index 3d57afe6e..09742acff 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -9,8 +9,8 @@ #include "modules.h" #include "commands.h" -patricia_tree<BotInfo, std::equal_to<ci::string> > BotListByNick; -patricia_tree<BotInfo> BotListByUID; +patricia_tree<BotInfo *, std::equal_to<ci::string> > BotListByNick; +patricia_tree<BotInfo *> BotListByUID; BotInfo *BotServ = NULL; BotInfo *ChanServ = NULL; diff --git a/src/botserv.cpp b/src/botserv.cpp index af3b0ee4e..82826b489 100644 --- a/src/botserv.cpp +++ b/src/botserv.cpp @@ -37,7 +37,7 @@ void get_botserv_stats(long *nrec, long *memuse) { long count = 0, mem = 0; - for (patricia_tree<BotInfo>::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; diff --git a/src/init.cpp b/src/init.cpp index 26f2144fb..81b9c2c36 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -37,7 +37,7 @@ void introduce_user(const Anope::string &user) } /* We make the bots go online */ - for (patricia_tree<User>::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 *u = *it; diff --git a/src/logger.cpp b/src/logger.cpp index dbcb9cf60..70ce988f6 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -36,7 +36,7 @@ void InitLogChannels(ServerConfig *config) c->SetFlag(CH_LOGCHAN); c->SetFlag(CH_PERSIST); - for (patricia_tree<BotInfo>::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; diff --git a/src/main.cpp b/src/main.cpp index a18d19a56..180af0729 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -172,7 +172,7 @@ void do_restart_services() if (quitmsg.empty()) quitmsg = "Restarting"; /* Send a quit for all of our bots */ - for (patricia_tree<BotInfo>::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; @@ -214,7 +214,7 @@ static void services_shutdown() if (started && UplinkSock) { /* Send a quit for all of our bots */ - for (patricia_tree<BotInfo>::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; @@ -495,7 +495,7 @@ int main(int ac, char **av, char **envp) FOREACH_MOD(I_OnServerDisconnect, OnServerDisconnect()); /* Clear all of our users, but not our bots */ - for (patricia_tree<User>::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; ++it; diff --git a/src/modes.cpp b/src/modes.cpp index 4d31f2232..7439c852c 100644 --- a/src/modes.cpp +++ b/src/modes.cpp @@ -78,7 +78,7 @@ void SetDefaultMLock(ServerConfig *config) } /* Apply the new modes to channels */ - for (patricia_tree<BotInfo>::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; diff --git a/src/operserv.cpp b/src/operserv.cpp index 727432585..e7de407bd 100644 --- a/src/operserv.cpp +++ b/src/operserv.cpp @@ -582,7 +582,7 @@ XLine *SNLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_ { Anope::string rreason = "G-Lined: " + reason; - for (patricia_tree<User>::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 *user = *it; ++it; @@ -683,7 +683,7 @@ XLine *SQLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_ } else { - for (patricia_tree<User>::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 *user = *it; ++it; diff --git a/src/servers.cpp b/src/servers.cpp index 3a19adcd1..acd26b4d3 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -86,7 +86,7 @@ Server::~Server() if (Capab.HasFlag(CAPAB_NOQUIT) || Capab.HasFlag(CAPAB_QS)) { - for (patricia_tree<User>::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; ++it; diff --git a/src/sessions.cpp b/src/sessions.cpp index aa5d1c29b..a90364160 100644 --- a/src/sessions.cpp +++ b/src/sessions.cpp @@ -35,17 +35,12 @@ * or a range thereof. The first exception that the host matches is the one * used. * - * "Session Limiting" is likely to slow down services when there are frequent - * client connects and disconnects. The size of the exception list can also - * play a large role in this performance decrease. It is therefore recommened - * that you keep the number of exceptions to a minimum. - * * -TheShadow (02 April 1999) */ /*************************************************************************/ -patricia_tree<Session> SessionList; +patricia_tree<Session *> SessionList; std::vector<Exception *> exceptions; @@ -58,7 +53,7 @@ void get_session_stats(long &count, long &mem) count = SessionList.size(); mem = sizeof(Session) * SessionList.size(); - for (patricia_tree<Session>::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; diff --git a/src/users.cpp b/src/users.cpp index ac16c61ac..58d931789 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -12,8 +12,8 @@ #include "services.h" #include "modules.h" -patricia_tree<User, std::equal_to<ci::string> > UserListByNick; -patricia_tree<User> UserListByUID; +patricia_tree<User *, std::equal_to<ci::string> > UserListByNick; +patricia_tree<User *> UserListByUID; int32 opcnt = 0; uint32 usercnt = 0, maxusercnt = 0; @@ -682,7 +682,7 @@ void get_user_stats(long &count, long &mem) { count = mem = 0; - for (patricia_tree<User>::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 *user = *it; |