1
0
mirror of https://github.com/anope/anope.git synced 2026-07-06 09:33:13 +02:00

Use std::tr1::unordered_map for a few of the larger maps

This commit is contained in:
Adam
2012-11-05 22:17:47 -05:00
parent 27ab6a686c
commit 53b2bdfe5e
41 changed files with 182 additions and 65 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
#include "access.h"
#include "bots.h"
Anope::map<Anope::map<Service *> > Service::services;
std::map<Anope::string, std::map<Anope::string, Service *> > Service::services;
void RegisterTypes()
{
+1 -2
View File
@@ -18,8 +18,7 @@
#include "extern.h"
#include "serialize.h"
serialize_checker<botinfo_map> BotListByNick("BotInfo");
serialize_checker<botinfouid_map> BotListByUID("BotInfo");
serialize_checker<botinfo_map> BotListByNick("BotInfo"), BotListByUID("BotInfo");
BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes) : User(nnick, nuser, nhost, "", "", Me, nreal, Anope::CurTime, "", ts6_uid_retrieve()), Flags<BotFlag, BI_END>(BotFlagString), Serializable("BotInfo"), botmodes(bmodes)
{
+1 -1
View File
@@ -27,7 +27,7 @@ BotInfo* findbot(const Anope::string &nick)
BotInfo *bi = NULL;
if (isdigit(nick[0]) && ircdproto->RequiresID)
{
botinfouid_map::iterator it = BotListByUID->find(nick);
botinfo_map::iterator it = BotListByUID->find(nick);
if (it != BotListByUID->end())
bi = it->second;
}
+1 -1
View File
@@ -118,7 +118,7 @@ UplinkSocket::~UplinkSocket()
{
FOREACH_MOD(I_OnServerDisconnect, OnServerDisconnect());
for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
{
User *u = it->second;
+2 -2
View File
@@ -16,7 +16,7 @@
#include "modules.h"
std::vector<Anope::string> SerializeType::type_order;
Anope::map<SerializeType *> SerializeType::types;
std::map<Anope::string, SerializeType *> SerializeType::types;
std::list<Serializable *> *Serializable::serializable_items;
stringstream::stringstream() : std::stringstream(), type(Serialize::DT_TEXT), _max(0)
@@ -204,7 +204,7 @@ Module* SerializeType::GetOwner() const
SerializeType *SerializeType::Find(const Anope::string &name)
{
Anope::map<SerializeType *>::iterator it = types.find(name);
std::map<Anope::string, SerializeType *>::iterator it = types.find(name);
if (it != types.end())
return it->second;
return NULL;
+2 -2
View File
@@ -91,7 +91,7 @@ Server::Server(Server *uplink, const Anope::string &name, unsigned hops, const A
}
/* We make the bots go online */
for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
{
User *u = it->second;
@@ -130,7 +130,7 @@ Server::~Server()
if (Capab.count("NOQUIT") > 0 || Capab.count("QS") > 0)
{
for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();)
for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();)
{
User *u = it->second;
++it;
+38
View File
@@ -295,6 +295,44 @@ bool cidr::operator<(const cidr &other) const
}
}
bool cidr::operator==(const cidr &other) const
{
return !(*this < other) && !(other < *this);
}
bool cidr::operator!=(const cidr &other) const
{
return !(*this == other);
}
size_t cidr::hash::operator()(const cidr &s) const
{
switch (s.addr.sa.sa_family)
{
case AF_INET:
{
unsigned int m = 0xFFFFFFFFU >> (32 - s.cidr_len);
return s.addr.sa4.sin_addr.s_addr & m;
}
case AF_INET6:
{
size_t h = 0;
for (int i = 0; i < s.cidr_len / 8; ++i)
h ^= (s.addr.sa6.sin6_addr.s6_addr[i] << ((i * 8) % sizeof(size_t)));
int remaining = s.cidr_len % 8;
unsigned char m = 0xFF << (8 - remaining);
h ^= s.addr.sa6.sin6_addr.s6_addr[s.cidr_len / 8] & m;
return h;
}
default:
throw CoreException("Unknown AFTYPE for cidr");
}
}
/** Receive something from the buffer
* @param s The socket
* @param buf The buf to read to
+3 -4
View File
@@ -22,8 +22,7 @@
#include "opertype.h"
#include "extern.h"
Anope::insensitive_map<User *> UserListByNick;
Anope::map<User *> UserListByUID;
user_map UserListByNick, UserListByUID;
int32_t opcnt = 0;
uint32_t usercnt = 0, maxusercnt = 0;
@@ -856,13 +855,13 @@ User *finduser(const Anope::string &nick)
{
if (isdigit(nick[0]) && ircdproto->RequiresID)
{
Anope::map<User *>::iterator it = UserListByUID.find(nick);
user_map::iterator it = UserListByUID.find(nick);
if (it != UserListByUID.end())
return it->second;
}
else
{
Anope::insensitive_map<User *>::iterator it = UserListByNick.find(nick);
user_map::iterator it = UserListByNick.find(nick);
if (it != UserListByNick.end())
return it->second;
}