diff options
author | Adam <Adam@anope.org> | 2013-02-15 14:22:23 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-02-15 19:01:46 -0500 |
commit | d9c18a6072521bb44418830d2ba1cda14389af20 (patch) | |
tree | 2163f6ba24b315a54a15f6419c194fc2236a1455 /include | |
parent | 73099b82e8619a87f894a0f787a582ee973bd177 (diff) |
Store hashes of the last commit instead of the last commit
Diffstat (limited to 'include')
-rw-r--r-- | include/anope.h | 12 | ||||
-rw-r--r-- | include/serialize.h | 12 |
2 files changed, 15 insertions, 9 deletions
diff --git a/include/anope.h b/include/anope.h index 1b978a8ba..6878a333c 100644 --- a/include/anope.h +++ b/include/anope.h @@ -308,7 +308,7 @@ 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 + struct hash_ci { inline size_t operator()(const string &s) const { @@ -316,6 +316,14 @@ namespace Anope } }; + struct hash_cs + { + inline size_t operator()(const string &s) const + { + return std::tr1::hash<std::string>()(s.str()); + } + }; + struct compare { inline bool operator()(const string &s1, const string &s2) const @@ -325,7 +333,7 @@ namespace Anope }; 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> { }; + template<typename T> class hash_map : public std::tr1::unordered_map<string, T, hash_ci, compare> { }; static const char *const compiled = __TIME__ " " __DATE__; diff --git a/include/serialize.h b/include/serialize.h index f495cdd73..23c865688 100644 --- a/include/serialize.h +++ b/include/serialize.h @@ -33,8 +33,7 @@ namespace Serialize virtual std::iostream& operator[](const Anope::string &key) = 0; virtual std::set<Anope::string> KeySet() const { throw CoreException("Not supported"); } - - virtual bool IsEqual(Data *other) { throw CoreException("Not supported"); } + virtual size_t Hash() const { throw CoreException("Not supported"); } virtual void SetType(const Anope::string &key, Type t) { } virtual Type GetType(const Anope::string &key) const { return DT_TEXT; } @@ -65,12 +64,11 @@ class CoreExport Serializable : public virtual Base private: /* Iterator into serializable_items */ std::list<Serializable *>::iterator s_iter; - /* The last serialized form of this object commited to the database */ - Serialize::Data *last_commit; + /* The hash of the last serialized form of this object commited to the database */ + size_t last_commit; /* The last time this object was commited to the database */ time_t last_commit_time; - Serializable(); protected: Serializable(const Anope::string &serialize_type); Serializable(const Serializable &); @@ -87,8 +85,8 @@ class CoreExport Serializable : public virtual Base */ void QueueUpdate(); - bool IsCached(Serialize::Data *); - void UpdateCache(Serialize::Data *); + bool IsCached(Serialize::Data &); + void UpdateCache(Serialize::Data &); bool IsTSCached(); void UpdateTS(); |