diff --git a/src/lol/base/map.h b/src/lol/base/map.h index d26efcfc..028300b2 100644 --- a/src/lol/base/map.h +++ b/src/lol/base/map.h @@ -43,7 +43,8 @@ public: inline V & operator[] (E const &key) { /* Look for the hash in our table and return the value if found. */ - int i = FindIndex(key); + uint32_t hash = ((Hash const &)*this)(key); + int i = FindIndex(key, hash); if (i >= 0) return m_array[i].m3; @@ -86,9 +87,8 @@ public: private: template - int FindIndex(E const &key) + inline int FindIndex(E const &key, uint32_t hash) { - uint32_t hash = ((Hash const &)*this)(key); for (int i = 0; i < m_array.Count(); ++i) if (m_array[i].m1 == hash) if (m_array[i].m2 == key) @@ -96,6 +96,13 @@ private: return -1; } + template + inline int FindIndex(E const &key) + { + uint32_t hash = ((Hash const &)*this)(key); + return FindIndex(key, hash); + } + Array m_array; };