Bug 997963, part 4 - Turn bundleCacheEntry_t::mBundle into an nsCOMPtr. r=ehsan

Also remove the now useless recycleEntry.
This commit is contained in:
Andrew McCreight 2014-04-21 09:41:57 -07:00
parent 234e5741cc
commit d50d87269d
2 changed files with 3 additions and 19 deletions

View File

@ -489,8 +489,7 @@ nsresult nsExtensibleStringBundle::GetSimpleEnumeration(nsISimpleEnumerator ** a
struct bundleCacheEntry_t : public LinkedListElement<bundleCacheEntry_t> {
nsAutoPtr<nsCStringKey> mHashKey;
// do not use a nsCOMPtr - this is a struct not a class!
nsIStringBundle* mBundle;
nsCOMPtr<nsIStringBundle> mBundle;
};
@ -561,9 +560,7 @@ nsStringBundleService::flushBundleCache()
mBundleMap.Reset();
while (!mBundleCache.isEmpty()) {
bundleCacheEntry_t *cacheEntry = mBundleCache.popFirst();
recycleEntry(cacheEntry);
delete cacheEntry;
delete mBundleCache.popFirst();
}
}
@ -637,17 +634,12 @@ nsStringBundleService::insertIntoCache(nsIStringBundle* aBundle,
#endif
mBundleMap.Remove(cacheEntry->mHashKey);
cacheEntry->remove();
// free up excess memory
recycleEntry(cacheEntry);
}
// at this point we have a new cacheEntry that doesn't exist
// in the hashtable, so set up the cacheEntry
cacheEntry->mBundle = aBundle;
NS_ADDREF(cacheEntry->mBundle);
cacheEntry->mHashKey = (nsCStringKey*)aHashKey->Clone();
cacheEntry->mBundle = aBundle;
// insert the entry into the cache and map, make it the MRU
mBundleMap.Put(cacheEntry->mHashKey, cacheEntry);
@ -655,12 +647,6 @@ nsStringBundleService::insertIntoCache(nsIStringBundle* aBundle,
return cacheEntry;
}
void
nsStringBundleService::recycleEntry(bundleCacheEntry_t *aEntry)
{
NS_RELEASE(aEntry->mBundle);
}
NS_IMETHODIMP
nsStringBundleService::CreateBundle(const char* aURLSpec,
nsIStringBundle** aResult)

View File

@ -44,8 +44,6 @@ private:
bundleCacheEntry_t *insertIntoCache(nsIStringBundle *aBundle,
nsCStringKey *aHashKey);
static void recycleEntry(bundleCacheEntry_t*);
nsHashtable mBundleMap;
mozilla::LinkedList<bundleCacheEntry_t> mBundleCache;