From: Laszlo T. <ave...@us...> - 2005-01-22 14:41:05
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7131 Modified Files: Cache.cpp Log Message: some optimisations so there are no double lookups Index: Cache.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Cache.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Cache.cpp 21 Jan 2005 18:45:12 -0000 1.1 --- Cache.cpp 22 Jan 2005 14:40:56 -0000 1.2 *************** *** 62,71 **** void *Cache::GetResource(ieResRef key) { ! if (hashmap.count(key) == 0) { return NULL; } ! ValueType *ret=&hashmap[key]; ! ret->nRefCount++; ! return ret->data; } --- 62,73 ---- void *Cache::GetResource(ieResRef key) { ! HashMapType::iterator m; ! ! m=hashmap.find(key); ! if (m == hashmap.end()) { return NULL; } ! (*m).second.nRefCount++; ! return (*m).second.data; } *************** *** 73,78 **** bool Cache::SetAt(ieResRef key, void *rValue) { ! if (hashmap.count(key) != 0) { ! return hashmap[key].data==rValue; } //this creates a new element --- 75,83 ---- bool Cache::SetAt(ieResRef key, void *rValue) { ! HashMapType::iterator m; ! ! m=hashmap.find(key); ! if (m!=hashmap.end()) { ! return (*m).second.data==rValue; } //this creates a new element *************** *** 86,101 **** int Cache::DecRef(ieResRef key, bool remove) { ! if (hashmap.count(key) == 0) { return -1; } if (remove) { ! hashmap.erase(key); return 0; } ! ValueType *ret=&hashmap[key]; ! if (ret->nRefCount) { ! ret->nRefCount--; ! return ret->nRefCount; } return -1; --- 91,107 ---- int Cache::DecRef(ieResRef key, bool remove) { ! HashMapType::iterator m; ! ! m=hashmap.find(key); ! if (m == hashmap.end()) { return -1; } if (remove) { ! hashmap.erase(m); return 0; } ! if ((*m).second.nRefCount) { ! return --(*m).second.nRefCount; } return -1; *************** *** 112,119 **** return 0; } ! ValueType *ret=&(*m).second; ! if (ret->nRefCount) { ! ret->nRefCount--; ! return ret->nRefCount; } } --- 118,123 ---- return 0; } ! if ((*m).second.nRefCount) { ! return --(*m).second.nRefCount; } } |