diff options
-rw-r--r-- | include/bancache.h | 2 | ||||
-rw-r--r-- | include/dns.h | 2 | ||||
-rw-r--r-- | include/hashcomp.h | 23 | ||||
-rw-r--r-- | include/inspircd.h | 4 | ||||
-rw-r--r-- | include/typedefs.h | 6 | ||||
-rw-r--r-- | src/hashcomp.cpp | 37 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.h | 2 | ||||
-rw-r--r-- | src/modules/m_watch.cpp | 7 |
8 files changed, 29 insertions, 54 deletions
diff --git a/include/bancache.h b/include/bancache.h index 450f711c4..7f51ca75e 100644 --- a/include/bancache.h +++ b/include/bancache.h @@ -51,7 +51,7 @@ class CoreExport BanCacheHit /* A container of ban cache items. * must be defined after class BanCacheHit. */ -typedef std::tr1::unordered_map<std::string, BanCacheHit*, std::tr1::hash<std::string> > BanCacheHash; +typedef TR1NS::unordered_map<std::string, BanCacheHit*, TR1NS::hash<std::string> > BanCacheHash; /** A manager for ban cache, which allocates and deallocates and checks cached bans. */ diff --git a/include/dns.h b/include/dns.h index d03af8918..120a8f428 100644 --- a/include/dns.h +++ b/include/dns.h @@ -101,7 +101,7 @@ class CoreExport CachedQuery /** DNS cache information. Holds IPs mapped to hostnames, and hostnames mapped to IPs. */ -typedef std::tr1::unordered_map<irc::string, CachedQuery, irc::hash> dnscache; +typedef TR1NS::unordered_map<irc::string, CachedQuery, irc::hash> dnscache; /** * Error types that class Resolver can emit to its error method. diff --git a/include/hashcomp.h b/include/hashcomp.h index e4b3cfe79..3c00844be 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -109,6 +109,11 @@ namespace irc bool operator()(const std::string& s1, const std::string& s2) const; }; + struct insensitive + { + size_t CoreExport operator()(const std::string &s) const; + }; + /** The irc_char_traits class is used for RFC-style comparison of strings. * This class is used to implement irc::string, a case-insensitive, RFC- * comparing string class. @@ -581,21 +586,3 @@ inline std::string& trim(std::string &str) return str; } - -namespace std -{ - namespace tr1 - { - - struct insensitive - { - size_t CoreExport operator()(const std::string &s) const; - }; - - /** Convert a string to lower case respecting RFC1459 - * @param n A string to lowercase - */ - void strlower(char *n); - - } -} diff --git a/include/inspircd.h b/include/inspircd.h index 929674eb3..25ef288aa 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -66,9 +66,11 @@ #include <unistd.h> #endif -#ifdef _WIN32 +#if defined _LIBCPP_VERSION || defined _WIN32 +# define TR1NS std # include <unordered_map> #else +# define TR1NS std::tr1 # include <tr1/unordered_map> #endif #include <sstream> diff --git a/include/typedefs.h b/include/typedefs.h index be7d4f796..b19426b6a 100644 --- a/include/typedefs.h +++ b/include/typedefs.h @@ -55,8 +55,8 @@ struct ResourceRecord; #include "hashcomp.h" #include "base.h" -typedef std::tr1::unordered_map<std::string, User*, std::tr1::insensitive, irc::StrHashComp> user_hash; -typedef std::tr1::unordered_map<std::string, Channel*, std::tr1::insensitive, irc::StrHashComp> chan_hash; +typedef TR1NS::unordered_map<std::string, User*, irc::insensitive, irc::StrHashComp> user_hash; +typedef TR1NS::unordered_map<std::string, Channel*, irc::insensitive, irc::StrHashComp> chan_hash; /** A list holding local users, this is the type of UserManager::local_users */ @@ -114,7 +114,7 @@ typedef std::map<std::string, file_cache> ConfigFileCache; /** A hash of commands used by the core */ -typedef std::tr1::unordered_map<std::string,Command*> Commandtable; +typedef TR1NS::unordered_map<std::string, Command*> Commandtable; /** Membership list of a channel */ typedef std::map<User*, Membership*> UserMembList; diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index a1e08bbf7..25abd471f 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -154,29 +154,6 @@ unsigned const char rfc_case_sensitive_map[256] = { 250, 251, 252, 253, 254, 255, // 250-255 }; -void std::tr1::strlower(char *n) -{ - if (n) - { - for (char* t = n; *t; t++) - *t = national_case_insensitive_map[(unsigned char)*t]; - } -} - -size_t std::tr1::insensitive::operator()(const std::string &s) const -{ - /* XXX: NO DATA COPIES! :) - * The hash function here is practically - * a copy of the one in STL's hash_fun.h, - * only with *x replaced with national_case_insensitive_map[*x]. - * This avoids a copy to use hash<const char*> - */ - register size_t t = 0; - for (std::string::const_iterator x = s.begin(); x != s.end(); ++x) /* ++x not x++, as its faster */ - t = 5 * t + national_case_insensitive_map[(unsigned char)*x]; - return t; -} - size_t CoreExport irc::hash::operator()(const irc::string &s) const { register size_t t = 0; @@ -195,6 +172,20 @@ bool irc::StrHashComp::operator()(const std::string& s1, const std::string& s2) return (national_case_insensitive_map[*n1] == national_case_insensitive_map[*n2]); } +size_t irc::insensitive::operator()(const std::string &s) const +{ + /* XXX: NO DATA COPIES! :) + * The hash function here is practically + * a copy of the one in STL's hash_fun.h, + * only with *x replaced with national_case_insensitive_map[*x]. + * This avoids a copy to use hash<const char*> + */ + register size_t t = 0; + for (std::string::const_iterator x = s.begin(); x != s.end(); ++x) /* ++x not x++, as its faster */ + t = 5 * t + national_case_insensitive_map[(unsigned char)*x]; + return t; +} + /****************************************************** * * This is the implementation of our special irc::string diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h index f67a0d3c1..36c161287 100644 --- a/src/modules/m_spanningtree/utils.h +++ b/src/modules/m_spanningtree/utils.h @@ -35,7 +35,7 @@ class SpanningTreeUtilities; /* This hash_map holds the hash equivalent of the server * tree, used for rapid linear lookups. */ -typedef std::tr1::unordered_map<std::string, TreeServer*, std::tr1::insensitive, irc::StrHashComp> server_hash; +typedef TR1NS::unordered_map<std::string, TreeServer*, irc::insensitive, irc::StrHashComp> server_hash; typedef std::set<TreeServer*> TreeServerList; diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp index 60ea79a83..fdb20be2d 100644 --- a/src/modules/m_watch.cpp +++ b/src/modules/m_watch.cpp @@ -92,12 +92,7 @@ * of users using WATCH. */ -/* - * Before you start screaming, this definition is only used here, so moving it to a header is pointless. - * Yes, it's horrid. Blame cl for being different. -- w00t - */ - -typedef std::tr1::unordered_map<irc::string, std::deque<User*>, irc::hash> watchentries; +typedef TR1NS::unordered_map<irc::string, std::deque<User*>, irc::hash> watchentries; typedef std::map<irc::string, std::string> watchlist; /* Who's watching each nickname. |