| 108 | } |
| 109 | |
| 110 | SimObject* SimNameDictionary::find(StringTableEntry name) |
| 111 | { |
| 112 | #ifndef USE_NEW_SIMDICTIONARY |
| 113 | // NULL is a valid lookup - it will always return NULL |
| 114 | if (!hashTable) |
| 115 | return NULL; |
| 116 | |
| 117 | Mutex::lockMutex(mutex); |
| 118 | |
| 119 | S32 idx = HashPointer(name) % hashTableSize; |
| 120 | SimObject *walk = hashTable[idx]; |
| 121 | while (walk) |
| 122 | { |
| 123 | if (walk->getName() == name) |
| 124 | { |
| 125 | Mutex::unlockMutex(mutex); |
| 126 | return walk; |
| 127 | } |
| 128 | walk = walk->nextNameObject; |
| 129 | } |
| 130 | |
| 131 | Mutex::unlockMutex(mutex); |
| 132 | return NULL; |
| 133 | #else |
| 134 | Mutex::lockMutex(mutex); |
| 135 | StringDictDef::iterator it = root.find(name); |
| 136 | SimObject* f = (it == root.end() ? NULL : it->second); |
| 137 | Mutex::unlockMutex(mutex); |
| 138 | return f; |
| 139 | #endif |
| 140 | } |
| 141 | |
| 142 | void SimNameDictionary::remove(SimObject* obj) |
| 143 | { |