diff --git a/dom/base/nsContentList.cpp b/dom/base/nsContentList.cpp index 6e337cf240ac..b19f5466f7a1 100644 --- a/dom/base/nsContentList.cpp +++ b/dom/base/nsContentList.cpp @@ -220,10 +220,9 @@ NS_GetContentList(nsINode* aRootNode, new PLDHashTable(&hash_table_ops, sizeof(ContentListHashEntry)); } - ContentListHashEntry *entry = nullptr; // First we look in our hashtable. Then we create a content list if needed - entry = static_cast - (PL_DHashTableAdd(gContentListHashTable, &hashKey, fallible)); + auto entry = static_cast + (gContentListHashTable->Add(&hashKey, fallible)); if (entry) list = entry->mContentList; @@ -329,8 +328,8 @@ GetFuncStringContentList(nsINode* aRootNode, if (gFuncStringContentListHashTable) { nsFuncStringCacheKey hashKey(aRootNode, aFunc, aString); - entry = static_cast - (PL_DHashTableAdd(gFuncStringContentListHashTable, &hashKey, fallible)); + entry = static_cast + (gFuncStringContentListHashTable->Add(&hashKey, fallible)); if (entry) { list = entry->mContentList; #ifdef DEBUG diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 27f2deecbca3..c5b453fb7021 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -4140,9 +4140,9 @@ nsContentUtils::GetListenerManagerForNode(nsINode *aNode) return nullptr; } - EventListenerManagerMapEntry *entry = - static_cast - (PL_DHashTableAdd(sEventListenerManagersHash, aNode, fallible)); + auto entry = + static_cast + (sEventListenerManagersHash->Add(aNode, fallible)); if (!entry) { return nullptr; diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 54575d375fb1..fa7133497863 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -3967,8 +3967,8 @@ nsDocument::SetSubDocumentFor(Element* aElement, nsIDocument* aSubDoc) } // Add a mapping to the hash table - SubDocMapEntry *entry = static_cast - (PL_DHashTableAdd(mSubDocuments, aElement, fallible)); + auto entry = + static_cast(mSubDocuments->Add(aElement, fallible)); if (!entry) { return NS_ERROR_OUT_OF_MEMORY; diff --git a/dom/base/nsPropertyTable.cpp b/dom/base/nsPropertyTable.cpp index a5f57c3353f7..09552437f136 100644 --- a/dom/base/nsPropertyTable.cpp +++ b/dom/base/nsPropertyTable.cpp @@ -206,8 +206,8 @@ nsPropertyTable::SetPropertyInternal(nsPropertyOwner aObject, // The current property value (if there is one) is replaced and the current // value is destroyed nsresult result = NS_OK; - PropertyListMapEntry *entry = static_cast - (PL_DHashTableAdd(&propertyList->mObjectValueMap, aObject, mozilla::fallible)); + auto entry = static_cast + (propertyList->mObjectValueMap.Add(aObject, mozilla::fallible)); if (!entry) return NS_ERROR_OUT_OF_MEMORY; // A nullptr entry->key is the sign that the entry has just been allocated diff --git a/dom/base/nsScriptNameSpaceManager.cpp b/dom/base/nsScriptNameSpaceManager.cpp index bc108f01692e..02c2691ff807 100644 --- a/dom/base/nsScriptNameSpaceManager.cpp +++ b/dom/base/nsScriptNameSpaceManager.cpp @@ -132,9 +132,7 @@ nsGlobalNameStruct * nsScriptNameSpaceManager::AddToHash(PLDHashTable *aTable, const nsAString *aKey, const char16_t **aClassName) { - GlobalNameMapEntry *entry = static_cast - (PL_DHashTableAdd(aTable, aKey, fallible)); - + auto entry = static_cast(aTable->Add(aKey, fallible)); if (!entry) { return nullptr; } diff --git a/dom/plugins/base/nsJSNPRuntime.cpp b/dom/plugins/base/nsJSNPRuntime.cpp index ed2217566cc4..d3f7b7dd16fc 100644 --- a/dom/plugins/base/nsJSNPRuntime.cpp +++ b/dom/plugins/base/nsJSNPRuntime.cpp @@ -1886,8 +1886,8 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, NPObject *npobj) } } - NPObjWrapperHashEntry *entry = static_cast - (PL_DHashTableAdd(sNPObjWrappers, npobj, fallible)); + auto entry = + static_cast(sNPObjWrappers->Add(npobj, fallible)); if (!entry) { // Out of memory @@ -2044,8 +2044,8 @@ LookupNPP(NPObject *npobj) return o->mNpp; } - NPObjWrapperHashEntry *entry = static_cast - (PL_DHashTableAdd(sNPObjWrappers, npobj, fallible)); + auto entry = + static_cast(sNPObjWrappers->Add(npobj, fallible)); if (!entry) { return nullptr; diff --git a/dom/xul/XULDocument.cpp b/dom/xul/XULDocument.cpp index 1a558d92e70f..a3150984437c 100644 --- a/dom/xul/XULDocument.cpp +++ b/dom/xul/XULDocument.cpp @@ -767,7 +767,7 @@ XULDocument::AddBroadcastListenerFor(Element& aBroadcaster, Element& aListener, (mBroadcasterMap->Search(&aBroadcaster)); if (!entry) { entry = static_cast - (PL_DHashTableAdd(mBroadcasterMap, &aBroadcaster, fallible)); + (mBroadcasterMap->Add(&aBroadcaster, fallible)); if (! entry) { aRv.Throw(NS_ERROR_OUT_OF_MEMORY); diff --git a/dom/xul/templates/nsContentSupportMap.h b/dom/xul/templates/nsContentSupportMap.h index 3667b9238e01..c9a136d9d179 100644 --- a/dom/xul/templates/nsContentSupportMap.h +++ b/dom/xul/templates/nsContentSupportMap.h @@ -25,8 +25,7 @@ public: ~nsContentSupportMap() { } nsresult Put(nsIContent* aElement, nsTemplateMatch* aMatch) { - PLDHashEntryHdr* hdr = - PL_DHashTableAdd(&mMap, aElement, mozilla::fallible); + PLDHashEntryHdr* hdr = mMap.Add(aElement, mozilla::fallible); if (!hdr) return NS_ERROR_OUT_OF_MEMORY; diff --git a/dom/xul/templates/nsTemplateMap.h b/dom/xul/templates/nsTemplateMap.h index a06e929c704f..ecdd9b981f45 100644 --- a/dom/xul/templates/nsTemplateMap.h +++ b/dom/xul/templates/nsTemplateMap.h @@ -27,8 +27,7 @@ public: Put(nsIContent* aContent, nsIContent* aTemplate) { NS_ASSERTION(!mTable.Search(aContent), "aContent already in map"); - Entry* entry = static_cast - (PL_DHashTableAdd(&mTable, aContent, fallible)); + auto entry = static_cast(mTable.Add(aContent, fallible)); if (entry) { entry->mContent = aContent; diff --git a/embedding/components/commandhandler/nsCommandParams.cpp b/embedding/components/commandhandler/nsCommandParams.cpp index 11841feffb82..e33da7348e21 100644 --- a/embedding/components/commandhandler/nsCommandParams.cpp +++ b/embedding/components/commandhandler/nsCommandParams.cpp @@ -219,8 +219,7 @@ nsCommandParams::GetOrMakeEntry(const char* aName, uint8_t aEntryType) return foundEntry; } - foundEntry = static_cast( - PL_DHashTableAdd(&mValuesHash, (void*)aName, fallible)); + foundEntry = static_cast(mValuesHash.Add((void*)aName, fallible)); if (!foundEntry) { return nullptr; } diff --git a/gfx/thebes/gfxFT2FontList.cpp b/gfx/thebes/gfxFT2FontList.cpp index 711994333968..3c8c627bfae0 100644 --- a/gfx/thebes/gfxFT2FontList.cpp +++ b/gfx/thebes/gfxFT2FontList.cpp @@ -700,8 +700,8 @@ public: } uint32_t filesize = strtoul(beginning, nullptr, 10); - FNCMapEntry* mapEntry = static_cast - (PL_DHashTableAdd(&mMap, filename.get(), fallible)); + auto mapEntry = + static_cast(mMap.Add(filename.get(), fallible)); if (mapEntry) { mapEntry->mFilename.Assign(filename); mapEntry->mTimestamp = timestamp; @@ -740,8 +740,8 @@ public: CacheFileInfo(const nsCString& aFileName, const nsCString& aFaceList, uint32_t aTimestamp, uint32_t aFilesize) { - FNCMapEntry* entry = static_cast - (PL_DHashTableAdd(&mMap, aFileName.get(), fallible)); + auto entry = + static_cast(mMap.Add(aFileName.get(), fallible)); if (entry) { entry->mFilename.Assign(aFileName); entry->mTimestamp = aTimestamp; diff --git a/js/xpconnect/src/XPCMaps.cpp b/js/xpconnect/src/XPCMaps.cpp index 4eb104862e86..83dae2f297ed 100644 --- a/js/xpconnect/src/XPCMaps.cpp +++ b/js/xpconnect/src/XPCMaps.cpp @@ -557,8 +557,7 @@ XPCNativeScriptableSharedMap::GetNewOrUsed(uint32_t flags, NS_PRECONDITION(si,"bad param"); XPCNativeScriptableShared key(flags, name); - Entry* entry = static_cast - (PL_DHashTableAdd(mTable, &key, fallible)); + auto entry = static_cast(mTable->Add(&key, fallible)); if (!entry) return false; diff --git a/js/xpconnect/src/XPCMaps.h b/js/xpconnect/src/XPCMaps.h index b860a668467e..d9f03710e195 100644 --- a/js/xpconnect/src/XPCMaps.h +++ b/js/xpconnect/src/XPCMaps.h @@ -123,8 +123,7 @@ public: NS_PRECONDITION(wrapper,"bad param"); nsISupports* obj = wrapper->GetIdentityObject(); MOZ_ASSERT(!Find(obj), "wrapper already in new scope!"); - Entry* entry = static_cast - (PL_DHashTableAdd(mTable, obj, mozilla::fallible)); + auto entry = static_cast(mTable->Add(obj, mozilla::fallible)); if (!entry) return nullptr; if (entry->key) @@ -186,8 +185,7 @@ public: { NS_PRECONDITION(clazz,"bad param"); const nsIID* iid = &clazz->GetIID(); - Entry* entry = static_cast - (PL_DHashTableAdd(mTable, iid, mozilla::fallible)); + auto entry = static_cast(mTable->Add(iid, mozilla::fallible)); if (!entry) return nullptr; if (entry->key) @@ -240,8 +238,7 @@ public: { NS_PRECONDITION(iface,"bad param"); const nsIID* iid = iface->GetIID(); - Entry* entry = static_cast - (PL_DHashTableAdd(mTable, iid, mozilla::fallible)); + auto entry = static_cast(mTable->Add(iid, mozilla::fallible)); if (!entry) return nullptr; if (entry->key) @@ -294,8 +291,7 @@ public: inline XPCNativeSet* Add(nsIClassInfo* info, XPCNativeSet* set) { NS_PRECONDITION(info,"bad param"); - Entry* entry = static_cast - (PL_DHashTableAdd(mTable, info, mozilla::fallible)); + auto entry = static_cast(mTable->Add(info, mozilla::fallible)); if (!entry) return nullptr; if (entry->key) @@ -351,8 +347,7 @@ public: inline XPCWrappedNativeProto* Add(nsIClassInfo* info, XPCWrappedNativeProto* proto) { NS_PRECONDITION(info,"bad param"); - Entry* entry = static_cast - (PL_DHashTableAdd(mTable, info, mozilla::fallible)); + auto entry = static_cast(mTable->Add(info, mozilla::fallible)); if (!entry) return nullptr; if (entry->key) @@ -413,8 +408,7 @@ public: { NS_PRECONDITION(key,"bad param"); NS_PRECONDITION(set,"bad param"); - Entry* entry = static_cast - (PL_DHashTableAdd(mTable, key, mozilla::fallible)); + auto entry = static_cast(mTable->Add(key, mozilla::fallible)); if (!entry) return nullptr; if (entry->key_value) @@ -485,8 +479,7 @@ public: inline nsIXPCFunctionThisTranslator* Add(REFNSIID iid, nsIXPCFunctionThisTranslator* obj) { - Entry* entry = static_cast - (PL_DHashTableAdd(mTable, &iid, mozilla::fallible)); + auto entry = static_cast(mTable->Add(&iid, mozilla::fallible)); if (!entry) return nullptr; entry->value = obj; @@ -557,8 +550,8 @@ public: inline XPCWrappedNativeProto* Add(XPCWrappedNativeProto* proto) { NS_PRECONDITION(proto,"bad param"); - PLDHashEntryStub* entry = static_cast - (PL_DHashTableAdd(mTable, proto, mozilla::fallible)); + auto entry = static_cast + (mTable->Add(proto, mozilla::fallible)); if (!entry) return nullptr; if (entry->key) diff --git a/layout/base/nsFrameManager.cpp b/layout/base/nsFrameManager.cpp index bc4e902d0b86..9985d73aa166 100644 --- a/layout/base/nsFrameManager.cpp +++ b/layout/base/nsFrameManager.cpp @@ -179,9 +179,8 @@ nsFrameManager::RegisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame) NS_PRECONDITION(aPlaceholderFrame, "null param unexpected"); NS_PRECONDITION(nsGkAtoms::placeholderFrame == aPlaceholderFrame->GetType(), "unexpected frame type"); - PlaceholderMapEntry *entry = static_cast - (PL_DHashTableAdd(&mPlaceholderMap, - aPlaceholderFrame->GetOutOfFlowFrame(), fallible)); + auto entry = static_cast + (mPlaceholderMap.Add(aPlaceholderFrame->GetOutOfFlowFrame(), fallible)); if (!entry) return NS_ERROR_OUT_OF_MEMORY; diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index 089d6be41103..430207c7a4ce 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -565,8 +565,7 @@ void RuleHash::AppendRuleToTable(PLDHashTable* aTable, const void* aKey, const RuleSelectorPair& aRuleInfo) { // Get a new or existing entry. - RuleHashTableEntry *entry = static_cast - (PL_DHashTableAdd(aTable, aKey, fallible)); + auto entry = static_cast(aTable->Add(aKey, fallible)); if (!entry) return; entry->mRules.AppendElement(RuleValue(aRuleInfo, mRuleCount++, mQuirksMode)); @@ -577,8 +576,7 @@ AppendRuleToTagTable(PLDHashTable* aTable, nsIAtom* aKey, const RuleValue& aRuleInfo) { // Get a new or exisiting entry - RuleHashTagTableEntry *entry = static_cast - (PL_DHashTableAdd(aTable, aKey, fallible)); + auto entry = static_cast(aTable->Add(aKey, fallible)); if (!entry) return; @@ -1003,9 +1001,8 @@ RuleCascadeData::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const nsTArray* RuleCascadeData::AttributeListFor(nsIAtom* aAttribute) { - AtomSelectorEntry *entry = - static_cast - (PL_DHashTableAdd(&mAttributeSelectors, aAttribute, fallible)); + auto entry = static_cast + (mAttributeSelectors.Add(aAttribute, fallible)); if (!entry) return nullptr; return &entry->mSelectors; @@ -3320,8 +3317,8 @@ AddSelector(RuleCascadeData* aCascade, if (negation == aSelectorInTopLevel) { for (nsAtomList* curID = negation->mIDList; curID; curID = curID->mNext) { - AtomSelectorEntry *entry = static_cast - (PL_DHashTableAdd(&aCascade->mIdSelectors, curID->mAtom, fallible)); + auto entry = static_cast + (aCascade->mIdSelectors.Add(curID->mAtom, fallible)); if (entry) { entry->mSelectors.AppendElement(SelectorPair(aSelectorInTopLevel, aRightmostSelector)); @@ -3335,9 +3332,8 @@ AddSelector(RuleCascadeData* aCascade, if (negation == aSelectorInTopLevel) { for (nsAtomList* curClass = negation->mClassList; curClass; curClass = curClass->mNext) { - AtomSelectorEntry *entry = static_cast - (PL_DHashTableAdd(&aCascade->mClassSelectors, curClass->mAtom, - fallible)); + auto entry = static_cast + (aCascade->mClassSelectors.Add(curClass->mAtom, fallible)); if (entry) { entry->mSelectors.AppendElement(SelectorPair(aSelectorInTopLevel, aRightmostSelector)); @@ -3661,9 +3657,8 @@ CascadeRuleEnumFunc(css::Rule* aRule, void* aData) for (nsCSSSelectorList *sel = styleRule->Selector(); sel; sel = sel->mNext) { int32_t weight = sel->mWeight; - RuleByWeightEntry *entry = static_cast( - PL_DHashTableAdd(&data->mRulesByWeight, NS_INT32_TO_PTR(weight), - fallible)); + auto entry = static_cast + (data->mRulesByWeight.Add(NS_INT32_TO_PTR(weight), fallible)); if (!entry) return false; entry->data.mWeight = weight; diff --git a/layout/style/nsHTMLStyleSheet.cpp b/layout/style/nsHTMLStyleSheet.cpp index a496ec0034b0..8cc79b663509 100644 --- a/layout/style/nsHTMLStyleSheet.cpp +++ b/layout/style/nsHTMLStyleSheet.cpp @@ -471,9 +471,8 @@ nsHTMLStyleSheet::SetVisitedLinkColor(nscolor aColor) already_AddRefed nsHTMLStyleSheet::UniqueMappedAttributes(nsMappedAttributes* aMapped) { - MappedAttrTableEntry *entry = - static_cast - (PL_DHashTableAdd(&mMappedAttrTable, aMapped, fallible)); + auto entry = static_cast + (mMappedAttrTable.Add(aMapped, fallible)); if (!entry) return nullptr; if (!entry->mAttributes) { @@ -501,8 +500,8 @@ nsHTMLStyleSheet::DropMappedAttributes(nsMappedAttributes* aMapped) nsIStyleRule* nsHTMLStyleSheet::LangRuleFor(const nsString& aLanguage) { - LangRuleTableEntry *entry = static_cast - (PL_DHashTableAdd(&mLangRuleTable, &aLanguage, fallible)); + auto entry = + static_cast(mLangRuleTable.Add(&aLanguage, fallible)); if (!entry) { NS_ASSERTION(false, "out of memory"); return nullptr; diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 4f2f5ae3146b..be7b02b437c9 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -1539,8 +1539,8 @@ nsRuleNode::Transition(nsIStyleRule* aRule, uint8_t aLevel, } if (ChildrenAreHashed()) { - ChildrenHashEntry *entry = static_cast - (PL_DHashTableAdd(ChildrenHash(), &key, fallible)); + auto entry = + static_cast(ChildrenHash()->Add(&key, fallible)); if (!entry) { NS_WARNING("out of memory"); return this; @@ -1606,8 +1606,8 @@ nsRuleNode::ConvertChildrenToHash(int32_t aNumKids) aNumKids); for (nsRuleNode* curr = ChildrenList(); curr; curr = curr->mNextSibling) { // This will never fail because of the initial size we gave the table. - ChildrenHashEntry *entry = static_cast( - PL_DHashTableAdd(hash, curr->mRule, fallible)); + auto entry = + static_cast(hash->Add(curr->mRule, fallible)); NS_ASSERTION(!entry->mRuleNode, "duplicate entries in list"); entry->mRuleNode = curr; } diff --git a/layout/tables/SpanningCellSorter.cpp b/layout/tables/SpanningCellSorter.cpp index 9d20372d5fc5..9d705955dcd0 100644 --- a/layout/tables/SpanningCellSorter.cpp +++ b/layout/tables/SpanningCellSorter.cpp @@ -68,9 +68,8 @@ SpanningCellSorter::AddCell(int32_t aColSpan, int32_t aRow, int32_t aCol) i->next = mArray[index]; mArray[index] = i; } else { - HashTableEntry *entry = static_cast - (PL_DHashTableAdd(&mHashTable, NS_INT32_TO_PTR(aColSpan), - fallible)); + auto entry = static_cast + (mHashTable.Add(NS_INT32_TO_PTR(aColSpan), fallible)); NS_ENSURE_TRUE(entry, false); NS_ASSERTION(entry->mColSpan == 0 || entry->mColSpan == aColSpan, diff --git a/modules/libpref/prefapi.cpp b/modules/libpref/prefapi.cpp index 7a2651c46165..338d7dbdc483 100644 --- a/modules/libpref/prefapi.cpp +++ b/modules/libpref/prefapi.cpp @@ -710,9 +710,7 @@ nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, uint32_t if (!gHashTable) return NS_ERROR_OUT_OF_MEMORY; - PrefHashEntry* pref = static_cast - (PL_DHashTableAdd(gHashTable, key, fallible)); - + auto pref = static_cast(gHashTable->Add(key, fallible)); if (!pref) return NS_ERROR_OUT_OF_MEMORY; diff --git a/netwerk/base/nsLoadGroup.cpp b/netwerk/base/nsLoadGroup.cpp index d88ff6d12990..3e55a3d17e82 100644 --- a/netwerk/base/nsLoadGroup.cpp +++ b/netwerk/base/nsLoadGroup.cpp @@ -491,9 +491,8 @@ nsLoadGroup::AddRequest(nsIRequest *request, nsISupports* ctxt) // Add the request to the list of active requests... // - RequestMapEntry *entry = static_cast - (PL_DHashTableAdd(&mRequests, request, fallible)); - + auto entry = + static_cast(mRequests.Add(request, fallible)); if (!entry) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/netwerk/cache/nsCacheEntry.cpp b/netwerk/cache/nsCacheEntry.cpp index 31b2c3faf457..80e03df563ca 100644 --- a/netwerk/cache/nsCacheEntry.cpp +++ b/netwerk/cache/nsCacheEntry.cpp @@ -435,7 +435,7 @@ nsCacheEntryHashTable::AddEntry( nsCacheEntry *cacheEntry) if (!initialized) return NS_ERROR_NOT_INITIALIZED; if (!cacheEntry) return NS_ERROR_NULL_POINTER; - hashEntry = PL_DHashTableAdd(&table, &(cacheEntry->mKey), fallible); + hashEntry = table.Add(&(cacheEntry->mKey), fallible); #ifndef DEBUG_dougt NS_ASSERTION(((nsCacheEntryHashTableEntry *)hashEntry)->cacheEntry == 0, "### nsCacheEntryHashTable::AddEntry - entry already used"); diff --git a/netwerk/cache/nsDiskCacheBinding.cpp b/netwerk/cache/nsDiskCacheBinding.cpp index e8cdedabbfe2..d123d0c67be8 100644 --- a/netwerk/cache/nsDiskCacheBinding.cpp +++ b/netwerk/cache/nsDiskCacheBinding.cpp @@ -229,12 +229,10 @@ nsDiskCacheBindery::AddBinding(nsDiskCacheBinding * binding) NS_ASSERTION(initialized, "nsDiskCacheBindery not initialized"); // find hash entry for key - HashTableEntry * hashEntry; - hashEntry = (HashTableEntry *) - PL_DHashTableAdd(&table, - (void *)(uintptr_t) binding->mRecord.HashNumber(), - fallible); - if (!hashEntry) return NS_ERROR_OUT_OF_MEMORY; + auto hashEntry = static_cast + (table.Add((void*)(uintptr_t)binding->mRecord.HashNumber(), fallible)); + if (!hashEntry) + return NS_ERROR_OUT_OF_MEMORY; if (hashEntry->mBinding == nullptr) { hashEntry->mBinding = binding; diff --git a/netwerk/dns/nsHostResolver.cpp b/netwerk/dns/nsHostResolver.cpp index 0927b15b59e8..02152cbd1edc 100644 --- a/netwerk/dns/nsHostResolver.cpp +++ b/netwerk/dns/nsHostResolver.cpp @@ -759,8 +759,7 @@ nsHostResolver::ResolveHost(const char *host, // callback, and proceed to do the lookup. nsHostKey key = { host, flags, af, netInterface }; - nsHostDBEnt *he = static_cast - (PL_DHashTableAdd(&mDB, &key, fallible)); + auto he = static_cast(mDB.Add(&key, fallible)); // if the record is null, the hash table OOM'd. if (!he) { diff --git a/netwerk/protocol/http/nsHttp.cpp b/netwerk/protocol/http/nsHttp.cpp index 05c4ca353d35..29d9ea12517b 100644 --- a/netwerk/protocol/http/nsHttp.cpp +++ b/netwerk/protocol/http/nsHttp.cpp @@ -115,8 +115,8 @@ nsHttp::CreateAtomTable() }; for (int i = 0; atoms[i]; ++i) { - PLDHashEntryStub *stub = reinterpret_cast - (PL_DHashTableAdd(sAtomTable, atoms[i], fallible)); + auto stub = static_cast + (sAtomTable->Add(atoms[i], fallible)); if (!stub) return NS_ERROR_OUT_OF_MEMORY; @@ -160,8 +160,7 @@ nsHttp::ResolveAtom(const char *str) MutexAutoLock lock(*sLock); - PLDHashEntryStub *stub = reinterpret_cast - (PL_DHashTableAdd(sAtomTable, str, fallible)); + auto stub = static_cast(sAtomTable->Add(str, fallible)); if (!stub) return atom; // out of memory diff --git a/parser/htmlparser/nsHTMLEntities.cpp b/parser/htmlparser/nsHTMLEntities.cpp index 06db92ea9206..11a7b923baab 100644 --- a/parser/htmlparser/nsHTMLEntities.cpp +++ b/parser/htmlparser/nsHTMLEntities.cpp @@ -92,9 +92,8 @@ nsHTMLEntities::AddRefTable(void) node < node_end; ++node) { // add to Entity->Unicode table - EntityNodeEntry* entry = - static_cast - (PL_DHashTableAdd(gEntityToUnicode, node->mStr, fallible)); + auto entry = static_cast + (gEntityToUnicode->Add(node->mStr, fallible)); NS_ASSERTION(entry, "Error adding an entry"); // Prefer earlier entries when we have duplication. if (!entry->node) @@ -102,9 +101,8 @@ nsHTMLEntities::AddRefTable(void) // add to Unicode->Entity table entry = static_cast - (PL_DHashTableAdd(gUnicodeToEntity, - NS_INT32_TO_PTR(node->mUnicode), - fallible)); + (gUnicodeToEntity->Add(NS_INT32_TO_PTR(node->mUnicode), + fallible)); NS_ASSERTION(entry, "Error adding an entry"); // Prefer earlier entries when we have duplication. if (!entry->node) diff --git a/rdf/base/nsInMemoryDataSource.cpp b/rdf/base/nsInMemoryDataSource.cpp index d183aec2cf9f..aec961ec4c29 100644 --- a/rdf/base/nsInMemoryDataSource.cpp +++ b/rdf/base/nsInMemoryDataSource.cpp @@ -315,8 +315,8 @@ public: void SetForwardArcs(nsIRDFResource* u, Assertion* as) { if (as) { - Entry* entry = static_cast - (PL_DHashTableAdd(&mForwardArcs, u, mozilla::fallible)); + auto entry = + static_cast(mForwardArcs.Add(u, mozilla::fallible)); if (entry) { entry->mNode = u; entry->mAssertions = as; @@ -330,8 +330,8 @@ public: void SetReverseArcs(nsIRDFNode* v, Assertion* as) { if (as) { - Entry* entry = static_cast - (PL_DHashTableAdd(&mReverseArcs, v, mozilla::fallible)); + auto entry = + static_cast(mReverseArcs.Add(v, mozilla::fallible)); if (entry) { entry->mNode = v; entry->mAssertions = as; @@ -1118,8 +1118,7 @@ InMemoryDataSource::LockedAssert(nsIRDFResource* aSource, } else { - hdr = PL_DHashTableAdd(next->u.hash.mPropertyHash, aProperty, - mozilla::fallible); + hdr = next->u.hash.mPropertyHash->Add(aProperty, mozilla::fallible); if (hdr) { Entry* entry = static_cast(hdr); @@ -1228,8 +1227,8 @@ InMemoryDataSource::LockedUnassert(nsIRDFResource* aSource, if (next && next->mNext) { PLDHashEntryHdr* hdr = - PL_DHashTableAdd(root->u.hash.mPropertyHash, aProperty, - mozilla::fallible); + root->u.hash.mPropertyHash->Add(aProperty, + mozilla::fallible); if (hdr) { Entry* entry = static_cast(hdr); entry->mNode = aProperty; @@ -1664,8 +1663,7 @@ InMemoryDataSource::EnsureFastContainment(nsIRDFResource* aSource) val->mNext = first; } else { - PLDHashEntryHdr* hdr = PL_DHashTableAdd(table, prop, - mozilla::fallible); + PLDHashEntryHdr* hdr = table->Add(prop, mozilla::fallible); if (hdr) { Entry* entry = static_cast(hdr); entry->mNode = prop; diff --git a/rdf/base/nsRDFService.cpp b/rdf/base/nsRDFService.cpp index 82a1ceb7f445..8577cb2affef 100644 --- a/rdf/base/nsRDFService.cpp +++ b/rdf/base/nsRDFService.cpp @@ -1140,7 +1140,7 @@ RDFServiceImpl::RegisterResource(nsIRDFResource* aResource, bool aReplace) aResource, (const char*) uri)); } else { - hdr = PL_DHashTableAdd(&mResources, uri, fallible); + hdr = mResources.Add(uri, fallible); if (! hdr) return NS_ERROR_OUT_OF_MEMORY; @@ -1376,7 +1376,7 @@ RDFServiceImpl::RegisterLiteral(nsIRDFLiteral* aLiteral) NS_ASSERTION(!mLiterals.Search(value), "literal already registered"); - PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mLiterals, value, fallible); + PLDHashEntryHdr *hdr = mLiterals.Add(value, fallible); if (! hdr) return NS_ERROR_OUT_OF_MEMORY; @@ -1426,7 +1426,7 @@ RDFServiceImpl::RegisterInt(nsIRDFInt* aInt) NS_ASSERTION(!mInts.Search(&value), "int already registered"); - PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mInts, &value, fallible); + PLDHashEntryHdr *hdr = mInts.Add(&value, fallible); if (! hdr) return NS_ERROR_OUT_OF_MEMORY; @@ -1476,7 +1476,7 @@ RDFServiceImpl::RegisterDate(nsIRDFDate* aDate) NS_ASSERTION(!mDates.Search(&value), "date already registered"); - PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mDates, &value, fallible); + PLDHashEntryHdr *hdr = mDates.Add(&value, fallible); if (! hdr) return NS_ERROR_OUT_OF_MEMORY; @@ -1521,7 +1521,7 @@ RDFServiceImpl::RegisterBlob(BlobImpl *aBlob) { NS_ASSERTION(!mBlobs.Search(&aBlob->mData), "blob already registered"); - PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mBlobs, &aBlob->mData, fallible); + PLDHashEntryHdr *hdr = mBlobs.Add(&aBlob->mData, fallible); if (! hdr) return NS_ERROR_OUT_OF_MEMORY; diff --git a/security/manager/ssl/nsCertTree.cpp b/security/manager/ssl/nsCertTree.cpp index 3bfe69aead93..856854f11e0c 100644 --- a/security/manager/ssl/nsCertTree.cpp +++ b/security/manager/ssl/nsCertTree.cpp @@ -186,8 +186,8 @@ CompareCacheHashEntry * nsCertTree::getCacheEntry(void *cache, void *aCert) { PLDHashTable &aCompareCache = *reinterpret_cast(cache); - CompareCacheHashEntryPtr *entryPtr = static_cast - (PL_DHashTableAdd(&aCompareCache, aCert, fallible)); + auto entryPtr = static_cast + (aCompareCache.Add(aCert, fallible)); return entryPtr ? entryPtr->entry : nullptr; } diff --git a/security/manager/ssl/nsNSSShutDown.cpp b/security/manager/ssl/nsNSSShutDown.cpp index d1fd24aecc2e..59f3e430ea1f 100644 --- a/security/manager/ssl/nsNSSShutDown.cpp +++ b/security/manager/ssl/nsNSSShutDown.cpp @@ -59,7 +59,7 @@ void nsNSSShutDownList::remember(nsNSSShutDownObject *o) PR_ASSERT(o); MutexAutoLock lock(singleton->mListLock); - PL_DHashTableAdd(&singleton->mObjects, o, fallible); + singleton->mObjects.Add(o, fallible); } void nsNSSShutDownList::forget(nsNSSShutDownObject *o) @@ -79,7 +79,7 @@ void nsNSSShutDownList::remember(nsOnPK11LogoutCancelObject *o) PR_ASSERT(o); MutexAutoLock lock(singleton->mListLock); - PL_DHashTableAdd(&singleton->mPK11LogoutCancelObjects, o, fallible); + singleton->mPK11LogoutCancelObjects.Add(o, fallible); } void nsNSSShutDownList::forget(nsOnPK11LogoutCancelObject *o) diff --git a/security/manager/ssl/nsSecureBrowserUIImpl.cpp b/security/manager/ssl/nsSecureBrowserUIImpl.cpp index 5a53abcacf6d..dceea63b6410 100644 --- a/security/manager/ssl/nsSecureBrowserUIImpl.cpp +++ b/security/manager/ssl/nsSecureBrowserUIImpl.cpp @@ -859,7 +859,7 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress, // means, there has already been data transfered. ReentrantMonitorAutoEnter lock(mReentrantMonitor); - PL_DHashTableAdd(&mTransferringRequests, aRequest, fallible); + mTransferringRequests.Add(aRequest, fallible); return NS_OK; } diff --git a/uriloader/base/nsDocLoader.cpp b/uriloader/base/nsDocLoader.cpp index 386de9f29fe6..2dabcb109383 100644 --- a/uriloader/base/nsDocLoader.cpp +++ b/uriloader/base/nsDocLoader.cpp @@ -1325,7 +1325,7 @@ nsDocLoader::RefreshAttempted(nsIWebProgress* aWebProgress, nsresult nsDocLoader::AddRequestInfo(nsIRequest *aRequest) { - if (!PL_DHashTableAdd(&mRequestInfoHash, aRequest, mozilla::fallible)) { + if (!mRequestInfoHash.Add(aRequest, mozilla::fallible)) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp index 83d995c3dbe6..4d850025e62f 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -917,8 +917,7 @@ CCGraph::AddNodeToMap(void* aPtr) return nullptr; } - PtrToNodeEntry* e = static_cast - (PL_DHashTableAdd(&mPtrToNodeMap, aPtr, fallible)); + auto e = static_cast(mPtrToNodeMap.Add(aPtr, fallible)); if (!e) { mOutOfMemory = true; MOZ_ASSERT(false, "Ran out of memory while building cycle collector graph"); diff --git a/xpcom/ds/nsAtomTable.cpp b/xpcom/ds/nsAtomTable.cpp index 342f2ef286ce..588d4b8b0307 100644 --- a/xpcom/ds/nsAtomTable.cpp +++ b/xpcom/ds/nsAtomTable.cpp @@ -541,7 +541,7 @@ GetAtomHashEntry(const char* aString, uint32_t aLength, uint32_t* aHashOut) EnsureTableExists(); AtomTableKey key(aString, aLength, aHashOut); // This is an infallible add. - return static_cast(PL_DHashTableAdd(gAtomTable, &key)); + return static_cast(gAtomTable->Add(&key)); } static inline AtomTableEntry* @@ -551,7 +551,7 @@ GetAtomHashEntry(const char16_t* aString, uint32_t aLength, uint32_t* aHashOut) EnsureTableExists(); AtomTableKey key(aString, aLength, aHashOut); // This is an infallible add. - return static_cast(PL_DHashTableAdd(gAtomTable, &key)); + return static_cast(gAtomTable->Add(&key)); } class CheckStaticAtomSizes diff --git a/xpcom/ds/nsPersistentProperties.cpp b/xpcom/ds/nsPersistentProperties.cpp index 4385282b4c13..b5b5d3697c79 100644 --- a/xpcom/ds/nsPersistentProperties.cpp +++ b/xpcom/ds/nsPersistentProperties.cpp @@ -523,8 +523,8 @@ nsPersistentProperties::SetStringProperty(const nsACString& aKey, nsAString& aOldValue) { const nsAFlatCString& flatKey = PromiseFlatCString(aKey); - PropertyTableEntry* entry = static_cast( - PL_DHashTableAdd(&mTable, flatKey.get(), mozilla::fallible)); + auto entry = static_cast + (mTable.Add(flatKey.get(), mozilla::fallible)); if (entry->mKey) { aOldValue = entry->mValue; diff --git a/xpcom/ds/nsStaticNameTable.cpp b/xpcom/ds/nsStaticNameTable.cpp index 9cae813bc878..e172e2054e9f 100644 --- a/xpcom/ds/nsStaticNameTable.cpp +++ b/xpcom/ds/nsStaticNameTable.cpp @@ -136,8 +136,7 @@ nsStaticCaseInsensitiveNameTable::nsStaticCaseInsensitiveNameTable( NameTableKey key(strPtr); - NameTableEntry* entry = static_cast - (PL_DHashTableAdd(&mNameTable, &key, fallible)); + auto entry = static_cast(mNameTable.Add(&key, fallible)); if (!entry) { continue; } diff --git a/xpcom/glue/nsTHashtable.h b/xpcom/glue/nsTHashtable.h index db46e9c13b44..4a880175de4b 100644 --- a/xpcom/glue/nsTHashtable.h +++ b/xpcom/glue/nsTHashtable.h @@ -143,16 +143,15 @@ public: */ EntryType* PutEntry(KeyType aKey) { - return static_cast // infallible add - (PL_DHashTableAdd(&mTable, EntryType::KeyToPointer(aKey))); + // infallible add + return static_cast(mTable.Add(EntryType::KeyToPointer(aKey))); } MOZ_WARN_UNUSED_RESULT EntryType* PutEntry(KeyType aKey, const fallible_t&) { - return static_cast - (PL_DHashTableAdd(&mTable, EntryType::KeyToPointer(aKey), - mozilla::fallible)); + return static_cast(mTable.Add(EntryType::KeyToPointer(aKey), + mozilla::fallible)); } /** diff --git a/xpcom/glue/pldhash.cpp b/xpcom/glue/pldhash.cpp index b5a307e5b8d7..335e1ceef067 100644 --- a/xpcom/glue/pldhash.cpp +++ b/xpcom/glue/pldhash.cpp @@ -568,7 +568,7 @@ PLDHashTable::Search(const void* aKey) return entry; } -MOZ_ALWAYS_INLINE PLDHashEntryHdr* +PLDHashEntryHdr* PLDHashTable::Add(const void* aKey, const mozilla::fallible_t&) { #ifdef DEBUG @@ -629,7 +629,7 @@ PLDHashTable::Add(const void* aKey, const mozilla::fallible_t&) return entry; } -MOZ_ALWAYS_INLINE PLDHashEntryHdr* +PLDHashEntryHdr* PLDHashTable::Add(const void* aKey) { PLDHashEntryHdr* entry = Add(aKey, fallible); @@ -678,19 +678,6 @@ PLDHashTable::RemoveEntry(PLDHashEntryHdr* aEntry) ShrinkIfAppropriate(); } -PLDHashEntryHdr* PL_DHASH_FASTCALL -PL_DHashTableAdd(PLDHashTable* aTable, const void* aKey, - const fallible_t& aFallible) -{ - return aTable->Add(aKey, aFallible); -} - -PLDHashEntryHdr* PL_DHASH_FASTCALL -PL_DHashTableAdd(PLDHashTable* aTable, const void* aKey) -{ - return aTable->Add(aKey); -} - void PL_DHASH_FASTCALL PL_DHashTableRemove(PLDHashTable* aTable, const void* aKey) { diff --git a/xpcom/glue/pldhash.h b/xpcom/glue/pldhash.h index d0b39509d539..bfd3860bea11 100644 --- a/xpcom/glue/pldhash.h +++ b/xpcom/glue/pldhash.h @@ -620,13 +620,6 @@ PL_DHashClearEntryStub(PLDHashTable* aTable, PLDHashEntryHdr* aEntry); const PLDHashTableOps* PL_DHashGetStubOps(void); -PLDHashEntryHdr* PL_DHASH_FASTCALL -PL_DHashTableAdd(PLDHashTable* aTable, const void* aKey, - const mozilla::fallible_t&); - -PLDHashEntryHdr* PL_DHASH_FASTCALL -PL_DHashTableAdd(PLDHashTable* aTable, const void* aKey); - void PL_DHASH_FASTCALL PL_DHashTableRemove(PLDHashTable* aTable, const void* aKey); diff --git a/xpcom/tests/gtest/TestPLDHash.cpp b/xpcom/tests/gtest/TestPLDHash.cpp index da960f2b5afa..37753227cd89 100644 --- a/xpcom/tests/gtest/TestPLDHash.cpp +++ b/xpcom/tests/gtest/TestPLDHash.cpp @@ -167,9 +167,9 @@ static const PLDHashTableOps trivialOps = { TEST(PLDHashTableTest, MoveSemantics) { PLDHashTable t1(&trivialOps, sizeof(PLDHashEntryStub)); - PL_DHashTableAdd(&t1, (const void*)88); + t1.Add((const void*)88); PLDHashTable t2(&trivialOps, sizeof(PLDHashEntryStub)); - PL_DHashTableAdd(&t2, (const void*)99); + t2.Add((const void*)99); t1 = mozilla::Move(t1); // self-move @@ -177,13 +177,13 @@ TEST(PLDHashTableTest, MoveSemantics) PLDHashTable t3(&trivialOps, sizeof(PLDHashEntryStub)); PLDHashTable t4(&trivialOps, sizeof(PLDHashEntryStub)); - PL_DHashTableAdd(&t3, (const void*)88); + t3.Add((const void*)88); t3 = mozilla::Move(t4); // non-empty overwritten with empty PLDHashTable t5(&trivialOps, sizeof(PLDHashEntryStub)); PLDHashTable t6(&trivialOps, sizeof(PLDHashEntryStub)); - PL_DHashTableAdd(&t6, (const void*)88); + t6.Add((const void*)88); t5 = mozilla::Move(t6); // empty overwritten with non-empty @@ -191,7 +191,7 @@ TEST(PLDHashTableTest, MoveSemantics) PLDHashTable t8(mozilla::Move(t7)); // new table constructed with uninited PLDHashTable t9(&trivialOps, sizeof(PLDHashEntryStub)); - PL_DHashTableAdd(&t9, (const void*)88); + t9.Add((const void*)88); PLDHashTable t10(mozilla::Move(t9)); // new table constructed with inited } @@ -205,19 +205,19 @@ TEST(PLDHashTableTest, Clear) t1.ClearAndPrepareForLength(100); ASSERT_EQ(t1.EntryCount(), 0u); - PL_DHashTableAdd(&t1, (const void*)77); - PL_DHashTableAdd(&t1, (const void*)88); - PL_DHashTableAdd(&t1, (const void*)99); + t1.Add((const void*)77); + t1.Add((const void*)88); + t1.Add((const void*)99); ASSERT_EQ(t1.EntryCount(), 3u); t1.Clear(); ASSERT_EQ(t1.EntryCount(), 0u); - PL_DHashTableAdd(&t1, (const void*)55); - PL_DHashTableAdd(&t1, (const void*)66); - PL_DHashTableAdd(&t1, (const void*)77); - PL_DHashTableAdd(&t1, (const void*)88); - PL_DHashTableAdd(&t1, (const void*)99); + t1.Add((const void*)55); + t1.Add((const void*)66); + t1.Add((const void*)77); + t1.Add((const void*)88); + t1.Add((const void*)99); ASSERT_EQ(t1.EntryCount(), 5u); t1.ClearAndPrepareForLength(8192); @@ -243,9 +243,9 @@ TEST(PLDHashTableTest, Iterator) } // Add three entries. - PL_DHashTableAdd(&t, (const void*)77); - PL_DHashTableAdd(&t, (const void*)88); - PL_DHashTableAdd(&t, (const void*)99); + t.Add((const void*)77); + t.Add((const void*)88); + t.Add((const void*)99); // Check the iterator goes through each entry once. bool saw77 = false, saw88 = false, saw99 = false; @@ -270,7 +270,7 @@ TEST(PLDHashTableTest, Iterator) // First, we insert 64 items, which results in a capacity of 128, and a load // factor of 50%. for (intptr_t i = 0; i < 64; i++) { - PL_DHashTableAdd(&t, (const void*)i); + t.Add((const void*)i); } ASSERT_EQ(t.EntryCount(), 64u); ASSERT_EQ(t.Capacity(), 128u); @@ -326,7 +326,7 @@ TEST(PLDHashTableTest, GrowToMaxCapacity) // Keep inserting elements until failure occurs because the table is full. size_t numInserted = 0; while (true) { - if (!PL_DHashTableAdd(t, (const void*)numInserted, mozilla::fallible)) { + if (!t->Add((const void*)numInserted, mozilla::fallible)) { break; } numInserted++;