From 59683492e5f8c3d67dff69e2aef2abb0f6517ff8 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 14 Sep 2015 14:23:24 -0700 Subject: [PATCH] Bug 1121760 (part 3) - Remove PL_DHashTableRemove(). r=poiru. --HG-- extra : rebase_source : c34d693de4aca45f2ea05c2767c8b1007c89df29 --- dom/base/nsContentList.cpp | 4 ++-- dom/base/nsDocument.cpp | 2 +- dom/base/nsScriptNameSpaceManager.cpp | 2 +- dom/plugins/base/nsJSNPRuntime.cpp | 2 +- dom/xul/templates/nsContentSupportMap.cpp | 2 +- dom/xul/templates/nsTemplateMap.h | 2 +- .../commandhandler/nsCommandParams.cpp | 2 +- js/xpconnect/src/XPCMaps.h | 16 ++++++++-------- layout/base/nsFrameManager.cpp | 3 +-- layout/style/nsHTMLStyleSheet.cpp | 2 +- netwerk/base/nsLoadGroup.cpp | 2 +- netwerk/cache/nsCacheEntry.cpp | 2 +- netwerk/cache/nsDiskCacheBinding.cpp | 3 +-- netwerk/dns/nsHostResolver.cpp | 6 +++--- rdf/base/nsInMemoryDataSource.cpp | 4 ++-- rdf/base/nsRDFService.cpp | 10 +++++----- security/manager/ssl/nsCertTree.cpp | 2 +- security/manager/ssl/nsNSSShutDown.cpp | 4 ++-- uriloader/base/nsDocLoader.cpp | 2 +- xpcom/ds/nsAtomTable.cpp | 2 +- xpcom/glue/nsTHashtable.h | 3 +-- xpcom/glue/pldhash.cpp | 8 +------- xpcom/glue/pldhash.h | 3 --- xpcom/tests/gtest/TestPLDHash.cpp | 2 +- 24 files changed, 39 insertions(+), 51 deletions(-) diff --git a/dom/base/nsContentList.cpp b/dom/base/nsContentList.cpp index b19f5466f7a1..168419b4b220 100644 --- a/dom/base/nsContentList.cpp +++ b/dom/base/nsContentList.cpp @@ -971,7 +971,7 @@ nsContentList::RemoveFromHashtable() if (!gContentListHashTable) return; - PL_DHashTableRemove(gContentListHashTable, &key); + gContentListHashTable->Remove(&key); if (gContentListHashTable->EntryCount() == 0) { delete gContentListHashTable; @@ -1012,7 +1012,7 @@ nsCacheableFuncStringContentList::RemoveFromFuncStringHashtable() } nsFuncStringCacheKey key(mRootNode, mFunc, mString); - PL_DHashTableRemove(gFuncStringContentListHashTable, &key); + gFuncStringContentListHashTable->Remove(&key); if (gFuncStringContentListHashTable->EntryCount() == 0) { delete gFuncStringContentListHashTable; diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index fa7133497863..1336fa4b5489 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -3948,7 +3948,7 @@ nsDocument::SetSubDocumentFor(Element* aElement, nsIDocument* aSubDoc) // aSubDoc is nullptr, remove the mapping if (mSubDocuments) { - PL_DHashTableRemove(mSubDocuments, aElement); + mSubDocuments->Remove(aElement); } } else { if (!mSubDocuments) { diff --git a/dom/base/nsScriptNameSpaceManager.cpp b/dom/base/nsScriptNameSpaceManager.cpp index 02c2691ff807..32f3d20cdea7 100644 --- a/dom/base/nsScriptNameSpaceManager.cpp +++ b/dom/base/nsScriptNameSpaceManager.cpp @@ -148,7 +148,7 @@ void nsScriptNameSpaceManager::RemoveFromHash(PLDHashTable *aTable, const nsAString *aKey) { - PL_DHashTableRemove(aTable, aKey); + aTable->Remove(aKey); } nsGlobalNameStruct* diff --git a/dom/plugins/base/nsJSNPRuntime.cpp b/dom/plugins/base/nsJSNPRuntime.cpp index d3f7b7dd16fc..0284a4dafaca 100644 --- a/dom/plugins/base/nsJSNPRuntime.cpp +++ b/dom/plugins/base/nsJSNPRuntime.cpp @@ -1755,7 +1755,7 @@ NPObjWrapper_Finalize(js::FreeOp *fop, JSObject *obj) NPObject *npobj = (NPObject *)::JS_GetPrivate(obj); if (npobj) { if (sNPObjWrappers) { - PL_DHashTableRemove(sNPObjWrappers, npobj); + sNPObjWrappers->Remove(npobj); } } diff --git a/dom/xul/templates/nsContentSupportMap.cpp b/dom/xul/templates/nsContentSupportMap.cpp index 062ad4ad6dcf..ec10fde74e6c 100644 --- a/dom/xul/templates/nsContentSupportMap.cpp +++ b/dom/xul/templates/nsContentSupportMap.cpp @@ -11,7 +11,7 @@ nsContentSupportMap::Remove(nsIContent* aElement) { nsIContent* child = aElement; do { - PL_DHashTableRemove(&mMap, child); + mMap.Remove(child); child = child->GetNextNode(aElement); } while(child); } diff --git a/dom/xul/templates/nsTemplateMap.h b/dom/xul/templates/nsTemplateMap.h index ecdd9b981f45..1056e8282c06 100644 --- a/dom/xul/templates/nsTemplateMap.h +++ b/dom/xul/templates/nsTemplateMap.h @@ -37,7 +37,7 @@ public: void Remove(nsIContent* aContent) { - PL_DHashTableRemove(&mTable, aContent); + mTable.Remove(aContent); for (nsIContent* child = aContent->GetFirstChild(); child; diff --git a/embedding/components/commandhandler/nsCommandParams.cpp b/embedding/components/commandhandler/nsCommandParams.cpp index e33da7348e21..87d68275c11f 100644 --- a/embedding/components/commandhandler/nsCommandParams.cpp +++ b/embedding/components/commandhandler/nsCommandParams.cpp @@ -200,7 +200,7 @@ nsCommandParams::SetISupportsValue(const char* aName, nsISupports* aValue) NS_IMETHODIMP nsCommandParams::RemoveValue(const char* aName) { - PL_DHashTableRemove(&mValuesHash, (void*)aName); + mValuesHash.Remove((void*)aName); return NS_OK; } diff --git a/js/xpconnect/src/XPCMaps.h b/js/xpconnect/src/XPCMaps.h index d9f03710e195..ecff46e4ee32 100644 --- a/js/xpconnect/src/XPCMaps.h +++ b/js/xpconnect/src/XPCMaps.h @@ -143,7 +143,7 @@ public: "nsISupports identity! This will most likely cause serious " "problems!"); #endif - PL_DHashTableRemove(mTable, wrapper->GetIdentityObject()); + mTable->Remove(wrapper->GetIdentityObject()); } inline uint32_t Count() { return mTable->EntryCount(); } @@ -198,7 +198,7 @@ public: inline void Remove(nsXPCWrappedJSClass* clazz) { NS_PRECONDITION(clazz,"bad param"); - PL_DHashTableRemove(mTable, &clazz->GetIID()); + mTable->Remove(&clazz->GetIID()); } inline uint32_t Count() { return mTable->EntryCount(); } @@ -251,7 +251,7 @@ public: inline void Remove(XPCNativeInterface* iface) { NS_PRECONDITION(iface,"bad param"); - PL_DHashTableRemove(mTable, iface->GetIID()); + mTable->Remove(iface->GetIID()); } inline uint32_t Count() { return mTable->EntryCount(); } @@ -304,7 +304,7 @@ public: inline void Remove(nsIClassInfo* info) { NS_PRECONDITION(info,"bad param"); - PL_DHashTableRemove(mTable, info); + mTable->Remove(info); } inline uint32_t Count() { return mTable->EntryCount(); } @@ -360,7 +360,7 @@ public: inline void Remove(nsIClassInfo* info) { NS_PRECONDITION(info,"bad param"); - PL_DHashTableRemove(mTable, info); + mTable->Remove(info); } inline uint32_t Count() { return mTable->EntryCount(); } @@ -428,7 +428,7 @@ public: NS_PRECONDITION(set,"bad param"); XPCNativeSetKey key(set, nullptr, 0); - PL_DHashTableRemove(mTable, &key); + mTable->Remove(&key); } inline uint32_t Count() { return mTable->EntryCount(); } @@ -489,7 +489,7 @@ public: inline void Remove(REFNSIID iid) { - PL_DHashTableRemove(mTable, &iid); + mTable->Remove(&iid); } inline uint32_t Count() { return mTable->EntryCount(); } @@ -563,7 +563,7 @@ public: inline void Remove(XPCWrappedNativeProto* proto) { NS_PRECONDITION(proto,"bad param"); - PL_DHashTableRemove(mTable, proto); + mTable->Remove(proto); } inline uint32_t Count() { return mTable->EntryCount(); } diff --git a/layout/base/nsFrameManager.cpp b/layout/base/nsFrameManager.cpp index 9985d73aa166..131b49b7d1f5 100644 --- a/layout/base/nsFrameManager.cpp +++ b/layout/base/nsFrameManager.cpp @@ -197,8 +197,7 @@ nsFrameManager::UnregisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame NS_PRECONDITION(nsGkAtoms::placeholderFrame == aPlaceholderFrame->GetType(), "unexpected frame type"); - PL_DHashTableRemove(&mPlaceholderMap, - aPlaceholderFrame->GetOutOfFlowFrame()); + mPlaceholderMap.Remove(aPlaceholderFrame->GetOutOfFlowFrame()); } void diff --git a/layout/style/nsHTMLStyleSheet.cpp b/layout/style/nsHTMLStyleSheet.cpp index 8cc79b663509..a4592ce601a2 100644 --- a/layout/style/nsHTMLStyleSheet.cpp +++ b/layout/style/nsHTMLStyleSheet.cpp @@ -492,7 +492,7 @@ nsHTMLStyleSheet::DropMappedAttributes(nsMappedAttributes* aMapped) uint32_t entryCount = mMappedAttrTable.EntryCount() - 1; #endif - PL_DHashTableRemove(&mMappedAttrTable, aMapped); + mMappedAttrTable.Remove(aMapped); NS_ASSERTION(entryCount == mMappedAttrTable.EntryCount(), "not removed"); } diff --git a/netwerk/base/nsLoadGroup.cpp b/netwerk/base/nsLoadGroup.cpp index 3e55a3d17e82..da1f74246586 100644 --- a/netwerk/base/nsLoadGroup.cpp +++ b/netwerk/base/nsLoadGroup.cpp @@ -528,7 +528,7 @@ nsLoadGroup::AddRequest(nsIRequest *request, nsISupports* ctxt) // the damage... // - PL_DHashTableRemove(&mRequests, request); + mRequests.Remove(request); rv = NS_OK; diff --git a/netwerk/cache/nsCacheEntry.cpp b/netwerk/cache/nsCacheEntry.cpp index 80e03df563ca..b2e90c690564 100644 --- a/netwerk/cache/nsCacheEntry.cpp +++ b/netwerk/cache/nsCacheEntry.cpp @@ -459,7 +459,7 @@ nsCacheEntryHashTable::RemoveEntry( nsCacheEntry *cacheEntry) nsCacheEntry *check = GetEntry(&(cacheEntry->mKey)); NS_ASSERTION(check == cacheEntry, "### Attempting to remove unknown cache entry!!!"); #endif - PL_DHashTableRemove(&table, &(cacheEntry->mKey)); + table.Remove(&(cacheEntry->mKey)); } PLDHashTable::Iterator diff --git a/netwerk/cache/nsDiskCacheBinding.cpp b/netwerk/cache/nsDiskCacheBinding.cpp index d123d0c67be8..0cef8aca9b5d 100644 --- a/netwerk/cache/nsDiskCacheBinding.cpp +++ b/netwerk/cache/nsDiskCacheBinding.cpp @@ -301,8 +301,7 @@ nsDiskCacheBindery::RemoveBinding(nsDiskCacheBinding * binding) if (binding == hashEntry->mBinding) { if (PR_CLIST_IS_EMPTY(binding)) { // remove this hash entry - PL_DHashTableRemove(&table, - (void*)(uintptr_t) binding->mRecord.HashNumber()); + table.Remove((void*)(uintptr_t) binding->mRecord.HashNumber()); return; } else { diff --git a/netwerk/dns/nsHostResolver.cpp b/netwerk/dns/nsHostResolver.cpp index 02152cbd1edc..e52ca6afb93a 100644 --- a/netwerk/dns/nsHostResolver.cpp +++ b/netwerk/dns/nsHostResolver.cpp @@ -619,7 +619,7 @@ nsHostResolver::FlushCache() nsHostRecord *rec = static_cast(node); node = node->next; PR_REMOVE_AND_INIT_LINK(rec); - PL_DHashTableRemove(&mDB, (nsHostKey *) rec); + mDB.Remove((nsHostKey *) rec); NS_RELEASE(rec); } } @@ -1266,7 +1266,7 @@ nsHostResolver::OnLookupComplete(nsHostRecord* rec, nsresult status, AddrInfo* r nsHostRecord *head = static_cast(PR_LIST_HEAD(&mEvictionQ)); PR_REMOVE_AND_INIT_LINK(head); - PL_DHashTableRemove(&mDB, (nsHostKey *) head); + mDB.Remove((nsHostKey *) head); if (!head->negative) { // record the age of the entry upon eviction. @@ -1342,7 +1342,7 @@ nsHostResolver::CancelAsyncRequest(const char *host, // If there are no more callbacks, remove the hash table entry if (recPtr && PR_CLIST_IS_EMPTY(&recPtr->callbacks)) { - PL_DHashTableRemove(&mDB, (nsHostKey *)recPtr); + mDB.Remove((nsHostKey *)recPtr); // If record is on a Queue, remove it and then deref it if (recPtr->next != recPtr) { PR_REMOVE_LINK(recPtr); diff --git a/rdf/base/nsInMemoryDataSource.cpp b/rdf/base/nsInMemoryDataSource.cpp index aec961ec4c29..59071cf64419 100644 --- a/rdf/base/nsInMemoryDataSource.cpp +++ b/rdf/base/nsInMemoryDataSource.cpp @@ -323,7 +323,7 @@ public: } } else { - PL_DHashTableRemove(&mForwardArcs, u); + mForwardArcs.Remove(u); } } @@ -338,7 +338,7 @@ public: } } else { - PL_DHashTableRemove(&mReverseArcs, v); + mReverseArcs.Remove(v); } } diff --git a/rdf/base/nsRDFService.cpp b/rdf/base/nsRDFService.cpp index 8577cb2affef..9368de2407c1 100644 --- a/rdf/base/nsRDFService.cpp +++ b/rdf/base/nsRDFService.cpp @@ -1186,7 +1186,7 @@ RDFServiceImpl::UnregisterResource(nsIRDFResource* aResource) NS_WARNING("resource was never registered"); #endif - PL_DHashTableRemove(&mResources, uri); + mResources.Remove(uri); return NS_OK; } @@ -1405,7 +1405,7 @@ RDFServiceImpl::UnregisterLiteral(nsIRDFLiteral* aLiteral) NS_ASSERTION(mLiterals.Search(value), "literal was never registered"); - PL_DHashTableRemove(&mLiterals, value); + mLiterals.Remove(value); // N.B. that we _don't_ release the literal: we only held a weak // reference to it in the hashtable. @@ -1455,7 +1455,7 @@ RDFServiceImpl::UnregisterInt(nsIRDFInt* aInt) NS_ASSERTION(mInts.Search(&value), "int was never registered"); - PL_DHashTableRemove(&mInts, &value); + mInts.Remove(&value); // N.B. that we _don't_ release the literal: we only held a weak // reference to it in the hashtable. @@ -1505,7 +1505,7 @@ RDFServiceImpl::UnregisterDate(nsIRDFDate* aDate) NS_ASSERTION(mDates.Search(&value), "date was never registered"); - PL_DHashTableRemove(&mDates, &value); + mDates.Remove(&value); // N.B. that we _don't_ release the literal: we only held a weak // reference to it in the hashtable. @@ -1545,7 +1545,7 @@ RDFServiceImpl::UnregisterBlob(BlobImpl *aBlob) { NS_ASSERTION(mBlobs.Search(&aBlob->mData), "blob was never registered"); - PL_DHashTableRemove(&mBlobs, &aBlob->mData); + mBlobs.Remove(&aBlob->mData); // N.B. that we _don't_ release the literal: we only held a weak // reference to it in the hashtable. diff --git a/security/manager/ssl/nsCertTree.cpp b/security/manager/ssl/nsCertTree.cpp index 856854f11e0c..435ddd2596c1 100644 --- a/security/manager/ssl/nsCertTree.cpp +++ b/security/manager/ssl/nsCertTree.cpp @@ -193,7 +193,7 @@ nsCertTree::getCacheEntry(void *cache, void *aCert) void nsCertTree::RemoveCacheEntry(void *key) { - PL_DHashTableRemove(&mCompareCache, key); + mCompareCache.Remove(key); } // CountOrganizations diff --git a/security/manager/ssl/nsNSSShutDown.cpp b/security/manager/ssl/nsNSSShutDown.cpp index 59f3e430ea1f..8912788efb80 100644 --- a/security/manager/ssl/nsNSSShutDown.cpp +++ b/security/manager/ssl/nsNSSShutDown.cpp @@ -69,7 +69,7 @@ void nsNSSShutDownList::forget(nsNSSShutDownObject *o) PR_ASSERT(o); MutexAutoLock lock(singleton->mListLock); - PL_DHashTableRemove(&singleton->mObjects, o); + singleton->mObjects.Remove(o); } void nsNSSShutDownList::remember(nsOnPK11LogoutCancelObject *o) @@ -89,7 +89,7 @@ void nsNSSShutDownList::forget(nsOnPK11LogoutCancelObject *o) PR_ASSERT(o); MutexAutoLock lock(singleton->mListLock); - PL_DHashTableRemove(&singleton->mPK11LogoutCancelObjects, o); + singleton->mPK11LogoutCancelObjects.Remove(o); } void nsNSSShutDownList::trackSSLSocketCreate() diff --git a/uriloader/base/nsDocLoader.cpp b/uriloader/base/nsDocLoader.cpp index 2dabcb109383..9e46fb1bff49 100644 --- a/uriloader/base/nsDocLoader.cpp +++ b/uriloader/base/nsDocLoader.cpp @@ -1334,7 +1334,7 @@ nsresult nsDocLoader::AddRequestInfo(nsIRequest *aRequest) void nsDocLoader::RemoveRequestInfo(nsIRequest *aRequest) { - PL_DHashTableRemove(&mRequestInfoHash, aRequest); + mRequestInfoHash.Remove(aRequest); } nsDocLoader::nsRequestInfo* nsDocLoader::GetRequestInfo(nsIRequest* aRequest) diff --git a/xpcom/ds/nsAtomTable.cpp b/xpcom/ds/nsAtomTable.cpp index 588d4b8b0307..6d306a2ae20a 100644 --- a/xpcom/ds/nsAtomTable.cpp +++ b/xpcom/ds/nsAtomTable.cpp @@ -397,7 +397,7 @@ AtomImpl::~AtomImpl() // |AtomTableClearEntry|. if (!IsPermanentInDestructor()) { AtomTableKey key(mString, mLength, mHash); - PL_DHashTableRemove(gAtomTable, &key); + gAtomTable->Remove(&key); if (gAtomTable->EntryCount() == 0) { delete gAtomTable; gAtomTable = nullptr; diff --git a/xpcom/glue/nsTHashtable.h b/xpcom/glue/nsTHashtable.h index 4a880175de4b..ad8d44554e40 100644 --- a/xpcom/glue/nsTHashtable.h +++ b/xpcom/glue/nsTHashtable.h @@ -160,8 +160,7 @@ public: */ void RemoveEntry(KeyType aKey) { - PL_DHashTableRemove(&mTable, - EntryType::KeyToPointer(aKey)); + mTable.Remove(EntryType::KeyToPointer(aKey)); } /** diff --git a/xpcom/glue/pldhash.cpp b/xpcom/glue/pldhash.cpp index 335e1ceef067..e68e6ac8e8fd 100644 --- a/xpcom/glue/pldhash.cpp +++ b/xpcom/glue/pldhash.cpp @@ -650,7 +650,7 @@ PLDHashTable::Add(const void* aKey) return entry; } -MOZ_ALWAYS_INLINE void +void PLDHashTable::Remove(const void* aKey) { #ifdef DEBUG @@ -678,12 +678,6 @@ PLDHashTable::RemoveEntry(PLDHashEntryHdr* aEntry) ShrinkIfAppropriate(); } -void PL_DHASH_FASTCALL -PL_DHashTableRemove(PLDHashTable* aTable, const void* aKey) -{ - aTable->Remove(aKey); -} - MOZ_ALWAYS_INLINE void PLDHashTable::RawRemove(PLDHashEntryHdr* aEntry) { diff --git a/xpcom/glue/pldhash.h b/xpcom/glue/pldhash.h index bfd3860bea11..44d4a4b3bac9 100644 --- a/xpcom/glue/pldhash.h +++ b/xpcom/glue/pldhash.h @@ -620,9 +620,6 @@ PL_DHashClearEntryStub(PLDHashTable* aTable, PLDHashEntryHdr* aEntry); const PLDHashTableOps* PL_DHashGetStubOps(void); -void PL_DHASH_FASTCALL -PL_DHashTableRemove(PLDHashTable* aTable, const void* aKey); - void PL_DHashTableRawRemove(PLDHashTable* aTable, PLDHashEntryHdr* aEntry); diff --git a/xpcom/tests/gtest/TestPLDHash.cpp b/xpcom/tests/gtest/TestPLDHash.cpp index 37753227cd89..bf4fc6e1532d 100644 --- a/xpcom/tests/gtest/TestPLDHash.cpp +++ b/xpcom/tests/gtest/TestPLDHash.cpp @@ -131,7 +131,7 @@ TEST(PLDHashTableTest, LazyStorage) ASSERT_TRUE(!t.Search((const void*)1)); // No result to check here, but call it to make sure it doesn't crash. - PL_DHashTableRemove(&t, (const void*)2); + t.Remove((const void*)2); for (auto iter = t.Iter(); !iter.Done(); iter.Next()) { ASSERT_TRUE(false); // shouldn't hit this on an empty table