diff options
author | Adam <Adam@anope.org> | 2012-11-05 22:17:47 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2012-11-06 11:02:12 -0500 |
commit | 53b2bdfe5e157a9e5ca5d08873edebcd04511ae1 (patch) | |
tree | f94c8603ffe475405ea668c629eddd7c8ba0891e /include/anope.h | |
parent | 27ab6a686cb271ea8eae7a243906af5bebeb83d7 (diff) |
Use std::tr1::unordered_map for a few of the larger maps
Diffstat (limited to 'include/anope.h')
-rw-r--r-- | include/anope.h | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/include/anope.h b/include/anope.h index 421f688ef..b6033b15c 100644 --- a/include/anope.h +++ b/include/anope.h @@ -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. |