From: Clifford Wolf Date: Wed, 31 Dec 2014 12:05:33 +0000 (+0100) Subject: hashlib cleanups and a fix X-Git-Tag: yosys-0.5~162 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b9e412423a681589b35f73412c43b23fee34560f;p=yosys.git hashlib cleanups and a fix --- diff --git a/kernel/hashlib.h b/kernel/hashlib.h index 7f2575d72..29f4f68b1 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -49,30 +49,30 @@ inline unsigned int mkhash_xorshift(unsigned int a) { } template struct hash_ops { - bool cmp(const T &a, const T &b) const { + static inline bool cmp(const T &a, const T &b) { return a == b; } - unsigned int hash(const T &a) const { + static inline unsigned int hash(const T &a) { return a.hash(); } }; template<> struct hash_ops { template - bool cmp(T a, T b) const { + static inline bool cmp(T a, T b) { return a == b; } template - unsigned int hash(T a) const { + static inline unsigned int hash(T a) { return a; } }; template<> struct hash_ops { - bool cmp(const std::string &a, const std::string &b) const { + static inline bool cmp(const std::string &a, const std::string &b) { return a == b; } - unsigned int hash(const std::string &a) const { + static inline unsigned int hash(const std::string &a) { unsigned int v = 0; for (auto c : a) v = mkhash(v, c); @@ -81,10 +81,10 @@ template<> struct hash_ops { }; template struct hash_ops> { - bool cmp(std::pair a, std::pair b) const { + static inline bool cmp(std::pair a, std::pair b) { return a == b; } - unsigned int hash(std::pair a) const { + static inline unsigned int hash(std::pair a) { hash_ops

p_ops; hash_ops q_ops; return mkhash(p_ops.hash(a.first), q_ops.hash(a.second)); @@ -92,10 +92,10 @@ template struct hash_ops> { }; template struct hash_ops> { - bool cmp(std::vector a, std::vector b) const { + static inline bool cmp(std::vector a, std::vector b) { return a == b; } - unsigned int hash(std::vector a) const { + static inline unsigned int hash(std::vector a) { hash_ops t_ops; unsigned int h = mkhash_init; for (auto k : a) @@ -105,13 +105,13 @@ template struct hash_ops> { }; struct hash_cstr_ops { - bool cmp(const char *a, const char *b) const { + static inline bool cmp(const char *a, const char *b) { for (int i = 0; a[i] || b[i]; i++) if (a[i] != b[i]) return false; return true; } - unsigned int hash(const char *a) const { + static inline unsigned int hash(const char *a) { unsigned int hash = mkhash_init; while (*a) hash = mkhash(hash, *(a++)); @@ -120,20 +120,20 @@ struct hash_cstr_ops { }; struct hash_ptr_ops { - bool cmp(const void *a, const void *b) const { + static inline bool cmp(const void *a, const void *b) { return a == b; } - unsigned int hash(const void *a) const { + static inline unsigned int hash(const void *a) { return (unsigned long)a; } }; struct hash_obj_ops { - bool cmp(const void *a, const void *b) const { + static inline bool cmp(const void *a, const void *b) { return a == b; } template - unsigned int hash(const T *a) const { + static inline unsigned int hash(const T *a) { return a->hash(); } }; @@ -703,7 +703,7 @@ public: iterator erase(iterator it) { - int hash = do_hash(it->first); + int hash = do_hash(*it); do_erase(it.index, hash); return ++it; }