mirror of
https://github.com/anope/anope.git
synced 2026-07-04 19:33:12 +02:00
Use std::tr1::unordered_map for a few of the larger maps
This commit is contained in:
+2
-2
@@ -20,8 +20,8 @@
|
||||
#include "memo.h"
|
||||
#include "base.h"
|
||||
|
||||
typedef Anope::insensitive_map<NickAlias *> nickalias_map;
|
||||
typedef Anope::insensitive_map<NickCore *> nickcore_map;
|
||||
typedef Anope::hash_map<NickAlias *> nickalias_map;
|
||||
typedef Anope::hash_map<NickCore *> nickcore_map;
|
||||
|
||||
extern CoreExport serialize_checker<nickalias_map> NickAliasList;
|
||||
extern CoreExport serialize_checker<nickcore_map> NickCoreList;
|
||||
|
||||
+21
-5
@@ -15,9 +15,6 @@
|
||||
|
||||
namespace Anope
|
||||
{
|
||||
template<typename T> class map : public std::map<string, T> { };
|
||||
template<typename T> class insensitive_map : public std::map<string, T, ci::less> { };
|
||||
|
||||
/**
|
||||
* A wrapper string class around all the other string classes, this class will
|
||||
* allow us to only require one type of string everywhere that can be converted
|
||||
@@ -232,7 +229,7 @@ namespace Anope
|
||||
/**
|
||||
* Get the string in lowercase.
|
||||
*/
|
||||
inline string lower()
|
||||
inline string lower() const
|
||||
{
|
||||
Anope::string new_string = *this;
|
||||
for (size_type i = 0; i < new_string.length(); ++i)
|
||||
@@ -243,7 +240,7 @@ namespace Anope
|
||||
/**
|
||||
* Get the string in uppercase.
|
||||
*/
|
||||
inline string upper()
|
||||
inline string upper() const
|
||||
{
|
||||
Anope::string new_string = *this;
|
||||
for (size_type i = 0; i < new_string.length(); ++i)
|
||||
@@ -286,6 +283,25 @@ namespace Anope
|
||||
inline const string operator+(const char *_str, const string &str) { string tmp(_str); tmp += str; return tmp; }
|
||||
inline const string operator+(const std::string &_str, const string &str) { string tmp(_str); tmp += str; return tmp; }
|
||||
|
||||
struct hash
|
||||
{
|
||||
inline size_t operator()(const string &s) const
|
||||
{
|
||||
return std::tr1::hash<std::string>()(s.lower().str());
|
||||
}
|
||||
};
|
||||
|
||||
struct compare
|
||||
{
|
||||
inline bool operator()(const string &s1, const string &s2) const
|
||||
{
|
||||
return s1.equals_ci(s2);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T> class map : public std::map<string, T, ci::less> { };
|
||||
template<typename T> class hash_map : public std::tr1::unordered_map<string, T, hash, compare> { };
|
||||
|
||||
static const char *const compiled = __TIME__ " " __DATE__;
|
||||
|
||||
/** The current system time, which is pretty close to being accurate.
|
||||
|
||||
+2
-4
@@ -14,11 +14,9 @@
|
||||
#include "commands.h"
|
||||
|
||||
|
||||
typedef Anope::insensitive_map<BotInfo *> botinfo_map;
|
||||
typedef Anope::map<BotInfo *> botinfouid_map;
|
||||
typedef Anope::map<BotInfo *> botinfo_map;
|
||||
|
||||
extern CoreExport serialize_checker<botinfo_map> BotListByNick;
|
||||
extern CoreExport serialize_checker<botinfouid_map> BotListByUID;
|
||||
extern CoreExport serialize_checker<botinfo_map> BotListByNick, BotListByUID;
|
||||
|
||||
/** Flags settable on a bot
|
||||
*/
|
||||
|
||||
+2
-1
@@ -14,7 +14,8 @@
|
||||
#include "modes.h"
|
||||
#include "serialize.h"
|
||||
|
||||
typedef Anope::insensitive_map<Channel *> channel_map;
|
||||
typedef Anope::hash_map<Channel *> channel_map;
|
||||
|
||||
extern CoreExport channel_map ChannelList;
|
||||
|
||||
struct UserContainer : public Extensible
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ const Anope::string CommandFlagStrings[] = {
|
||||
|
||||
struct CommandInfo
|
||||
{
|
||||
typedef Anope::insensitive_map<CommandInfo> map;
|
||||
typedef Anope::map<CommandInfo> map;
|
||||
|
||||
Anope::string name;
|
||||
Anope::string permission;
|
||||
|
||||
@@ -25,7 +25,7 @@ template<typename T> struct CoreExport ExtensibleItemClass : T, ExtensibleItem
|
||||
class CoreExport Extensible
|
||||
{
|
||||
private:
|
||||
typedef Anope::map<ExtensibleItem *> extensible_map;
|
||||
typedef std::map<Anope::string, ExtensibleItem *> extensible_map;
|
||||
extensible_map extension_items;
|
||||
|
||||
public:
|
||||
|
||||
@@ -16,6 +16,12 @@
|
||||
#include <string>
|
||||
#include <locale>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <tr1/unordered_map>
|
||||
#else
|
||||
#include <unordered_map>
|
||||
#endif
|
||||
|
||||
#include "services.h"
|
||||
|
||||
namespace Anope
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "serialize.h"
|
||||
#include "bots.h"
|
||||
|
||||
typedef Anope::insensitive_map<ChannelInfo *> registered_channel_map;
|
||||
typedef Anope::hash_map<ChannelInfo *> registered_channel_map;
|
||||
|
||||
extern CoreExport serialize_checker<registered_channel_map> RegisteredChannelList;
|
||||
|
||||
|
||||
+1
-1
@@ -109,7 +109,7 @@ class CoreExport SerializeType
|
||||
typedef Serializable* (*unserialize_func)(Serializable *obj, Serialize::Data &);
|
||||
|
||||
static std::vector<Anope::string> type_order;
|
||||
static Anope::map<SerializeType *> types;
|
||||
static std::map<Anope::string, SerializeType *> types;
|
||||
|
||||
Anope::string name;
|
||||
unserialize_func unserialize;
|
||||
|
||||
+7
-7
@@ -17,14 +17,14 @@
|
||||
|
||||
class CoreExport Service : public virtual Base
|
||||
{
|
||||
static Anope::map<Anope::map<Service *> > services;
|
||||
static std::map<Anope::string, std::map<Anope::string, Service *> > services;
|
||||
public:
|
||||
static Service *FindService(const Anope::string &t, const Anope::string &n)
|
||||
{
|
||||
Anope::map<Anope::map<Service *> >::iterator it = services.find(t);
|
||||
std::map<Anope::string, std::map<Anope::string, Service *> >::iterator it = services.find(t);
|
||||
if (it != services.end())
|
||||
{
|
||||
Anope::map<Service *>::iterator it2 = it->second.find(n);
|
||||
std::map<Anope::string, Service *>::iterator it2 = it->second.find(n);
|
||||
if (it2 != it->second.end())
|
||||
return it2->second;
|
||||
}
|
||||
@@ -35,9 +35,9 @@ class CoreExport Service : public virtual Base
|
||||
static std::vector<Anope::string> GetServiceKeys(const Anope::string &t)
|
||||
{
|
||||
std::vector<Anope::string> keys;
|
||||
Anope::map<Anope::map<Service *> >::iterator it = services.find(t);
|
||||
std::map<Anope::string, std::map<Anope::string, Service *> >::iterator it = services.find(t);
|
||||
if (it != services.end())
|
||||
for (Anope::map<Service *>::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2)
|
||||
for (std::map<Anope::string, Service *>::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2)
|
||||
keys.push_back(it2->first);
|
||||
return keys;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ class CoreExport Service : public virtual Base
|
||||
|
||||
void Register()
|
||||
{
|
||||
Anope::map<Service *> &smap = services[this->type];
|
||||
std::map<Anope::string, Service *> &smap = services[this->type];
|
||||
if (smap.find(this->name) != smap.end())
|
||||
throw ModuleException("Service " + this->type + " with name " + this->name + " already exists");
|
||||
smap[this->name] = this;
|
||||
@@ -66,7 +66,7 @@ class CoreExport Service : public virtual Base
|
||||
|
||||
void Unregister()
|
||||
{
|
||||
Anope::map<Service *> &smap = services[this->type];
|
||||
std::map<Anope::string, Service *> &smap = services[this->type];
|
||||
smap.erase(this->name);
|
||||
if (smap.empty())
|
||||
services.erase(this->type);
|
||||
|
||||
@@ -90,7 +90,15 @@ class CoreExport cidr
|
||||
cidr(const Anope::string &ip, unsigned char len);
|
||||
Anope::string mask() const;
|
||||
bool match(sockaddrs &other);
|
||||
|
||||
bool operator<(const cidr &other) const;
|
||||
bool operator==(const cidr &other) const;
|
||||
bool operator!=(const cidr &other) const;
|
||||
|
||||
struct hash
|
||||
{
|
||||
size_t operator()(const cidr &s) const;
|
||||
};
|
||||
};
|
||||
|
||||
class SocketException : public CoreException
|
||||
|
||||
+3
-2
@@ -15,8 +15,9 @@
|
||||
#include "commands.h"
|
||||
#include "account.h"
|
||||
|
||||
extern CoreExport Anope::insensitive_map<User *> UserListByNick;
|
||||
extern CoreExport Anope::map<User *> UserListByUID;
|
||||
typedef Anope::hash_map<User *> user_map;
|
||||
|
||||
extern CoreExport user_map UserListByNick, UserListByUID;
|
||||
|
||||
class CoreExport ChannelStatus : public Flags<ChannelModeName, CMODE_END * 2>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user