diff --git a/Engine/source/console/simDictionary.cpp b/Engine/source/console/simDictionary.cpp index 5196d994b..c1b0bf056 100644 --- a/Engine/source/console/simDictionary.cpp +++ b/Engine/source/console/simDictionary.cpp @@ -101,7 +101,7 @@ void SimNameDictionary::insert(SimObject* obj) hashTableSize = newHashTableSize; } #else - root[StringTable->insert(obj->objectName)] = obj; + root[obj->objectName] = obj; #endif Mutex::unlockMutex(mutex); } @@ -131,7 +131,8 @@ SimObject* SimNameDictionary::find(StringTableEntry name) return NULL; #else Mutex::lockMutex(mutex); - SimObject* f = root[StringTable->insert(name)]; + StringDictDef::iterator it = root.find(name); + SimObject* f = (it == root.end() ? NULL : it->second); Mutex::unlockMutex(mutex); return f; #endif @@ -159,8 +160,8 @@ void SimNameDictionary::remove(SimObject* obj) walk = &((*walk)->nextNameObject); } #else - const char* name = StringTable->insert(obj->objectName); - if (root[name]) + const char* name = obj->objectName; + if (root.find(name) != root.end()) root.erase(name); #endif Mutex::unlockMutex(mutex); @@ -231,7 +232,7 @@ void SimManagerNameDictionary::insert(SimObject* obj) hashTableSize = newHashTableSize; } #else - root[StringTable->insert(obj->objectName)] = obj; + root[obj->objectName] = obj; #endif Mutex::unlockMutex(mutex); } @@ -258,7 +259,8 @@ SimObject* SimManagerNameDictionary::find(StringTableEntry name) return NULL; #else - SimObject* f = root[StringTable->insert(name)]; + StringDictDef::iterator it = root.find(name); + SimObject* f = (it == root.end() ? NULL : it->second); Mutex::unlockMutex(mutex); return f; #endif @@ -287,8 +289,8 @@ void SimManagerNameDictionary::remove(SimObject* obj) walk = &((*walk)->nextManagerNameObject); } #else - const char* name = StringTable->insert(obj->objectName); - if (root[name]) + StringTableEntry name = obj->objectName; + if (root.find(name) != root.end()) root.erase(name); #endif Mutex::unlockMutex(mutex); @@ -345,7 +347,8 @@ SimObject* SimIdDictionary::find(S32 id) return NULL; #else - SimObject* f = root[id]; + SimObjectIdDictDef::iterator it = root.find(id); + SimObject* f = (it == root.end() ? NULL : it->second); Mutex::unlockMutex(mutex); return f; #endif diff --git a/Engine/source/console/simDictionary.h b/Engine/source/console/simDictionary.h index 27d27de29..f32c8b8d0 100644 --- a/Engine/source/console/simDictionary.h +++ b/Engine/source/console/simDictionary.h @@ -41,26 +41,30 @@ class SimObject; #include #include +#ifndef _SIM_H_ +#include "console/sim.h" +#endif + #include "core/strings/stringFunctions.h" -struct DictionaryHash +struct StringTableEntryHash { - inline size_t operator()(const char* val) const + inline size_t operator()(StringTableEntry val) const { - return (long)val; + return (size_t)val; } }; -struct eqstr +struct StringTableEntryEq { - inline bool operator()(const char *s1, const char *s2) const + inline bool operator()(StringTableEntry s1, StringTableEntry s2) const { - return dStrcmp(s1, s2) == 0; + return s1 == s2; } }; -typedef std::unordered_map StringDictDef; -typedef std::unordered_map U32DictDef; +typedef std::unordered_map StringDictDef; +typedef std::unordered_map SimObjectIdDictDef; #endif @@ -137,7 +141,7 @@ class SimIdDictionary }; SimObject *table[DefaultTableSize]; #else - U32DictDef root; + SimObjectIdDictDef root; #endif void *mutex;