Bug 1121760 (part 2) - Remove PL_DHashTableAdd(). r=poiru.

This commit is contained in:
Nicholas Nethercote 2015-09-14 14:23:12 -07:00
parent e600d6de49
commit 6f753fbb80
39 changed files with 121 additions and 177 deletions

View File

@ -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<ContentListHashEntry *>
(PL_DHashTableAdd(gContentListHashTable, &hashKey, fallible));
auto entry = static_cast<ContentListHashEntry*>
(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<FuncStringContentListHashEntry *>
(PL_DHashTableAdd(gFuncStringContentListHashTable, &hashKey, fallible));
entry = static_cast<FuncStringContentListHashEntry*>
(gFuncStringContentListHashTable->Add(&hashKey, fallible));
if (entry) {
list = entry->mContentList;
#ifdef DEBUG

View File

@ -4140,9 +4140,9 @@ nsContentUtils::GetListenerManagerForNode(nsINode *aNode)
return nullptr;
}
EventListenerManagerMapEntry *entry =
static_cast<EventListenerManagerMapEntry *>
(PL_DHashTableAdd(sEventListenerManagersHash, aNode, fallible));
auto entry =
static_cast<EventListenerManagerMapEntry*>
(sEventListenerManagersHash->Add(aNode, fallible));
if (!entry) {
return nullptr;

View File

@ -3967,8 +3967,8 @@ nsDocument::SetSubDocumentFor(Element* aElement, nsIDocument* aSubDoc)
}
// Add a mapping to the hash table
SubDocMapEntry *entry = static_cast<SubDocMapEntry*>
(PL_DHashTableAdd(mSubDocuments, aElement, fallible));
auto entry =
static_cast<SubDocMapEntry*>(mSubDocuments->Add(aElement, fallible));
if (!entry) {
return NS_ERROR_OUT_OF_MEMORY;

View File

@ -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<PropertyListMapEntry*>
(PL_DHashTableAdd(&propertyList->mObjectValueMap, aObject, mozilla::fallible));
auto entry = static_cast<PropertyListMapEntry*>
(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

View File

@ -132,9 +132,7 @@ nsGlobalNameStruct *
nsScriptNameSpaceManager::AddToHash(PLDHashTable *aTable, const nsAString *aKey,
const char16_t **aClassName)
{
GlobalNameMapEntry *entry = static_cast<GlobalNameMapEntry *>
(PL_DHashTableAdd(aTable, aKey, fallible));
auto entry = static_cast<GlobalNameMapEntry*>(aTable->Add(aKey, fallible));
if (!entry) {
return nullptr;
}

View File

@ -1886,8 +1886,8 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, NPObject *npobj)
}
}
NPObjWrapperHashEntry *entry = static_cast<NPObjWrapperHashEntry *>
(PL_DHashTableAdd(sNPObjWrappers, npobj, fallible));
auto entry =
static_cast<NPObjWrapperHashEntry*>(sNPObjWrappers->Add(npobj, fallible));
if (!entry) {
// Out of memory
@ -2044,8 +2044,8 @@ LookupNPP(NPObject *npobj)
return o->mNpp;
}
NPObjWrapperHashEntry *entry = static_cast<NPObjWrapperHashEntry *>
(PL_DHashTableAdd(sNPObjWrappers, npobj, fallible));
auto entry =
static_cast<NPObjWrapperHashEntry*>(sNPObjWrappers->Add(npobj, fallible));
if (!entry) {
return nullptr;

View File

@ -767,7 +767,7 @@ XULDocument::AddBroadcastListenerFor(Element& aBroadcaster, Element& aListener,
(mBroadcasterMap->Search(&aBroadcaster));
if (!entry) {
entry = static_cast<BroadcasterMapEntry*>
(PL_DHashTableAdd(mBroadcasterMap, &aBroadcaster, fallible));
(mBroadcasterMap->Add(&aBroadcaster, fallible));
if (! entry) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);

View File

@ -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;

View File

@ -27,8 +27,7 @@ public:
Put(nsIContent* aContent, nsIContent* aTemplate) {
NS_ASSERTION(!mTable.Search(aContent), "aContent already in map");
Entry* entry = static_cast<Entry*>
(PL_DHashTableAdd(&mTable, aContent, fallible));
auto entry = static_cast<Entry*>(mTable.Add(aContent, fallible));
if (entry) {
entry->mContent = aContent;

View File

@ -219,8 +219,7 @@ nsCommandParams::GetOrMakeEntry(const char* aName, uint8_t aEntryType)
return foundEntry;
}
foundEntry = static_cast<HashEntry*>(
PL_DHashTableAdd(&mValuesHash, (void*)aName, fallible));
foundEntry = static_cast<HashEntry*>(mValuesHash.Add((void*)aName, fallible));
if (!foundEntry) {
return nullptr;
}

View File

@ -700,8 +700,8 @@ public:
}
uint32_t filesize = strtoul(beginning, nullptr, 10);
FNCMapEntry* mapEntry = static_cast<FNCMapEntry*>
(PL_DHashTableAdd(&mMap, filename.get(), fallible));
auto mapEntry =
static_cast<FNCMapEntry*>(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<FNCMapEntry*>
(PL_DHashTableAdd(&mMap, aFileName.get(), fallible));
auto entry =
static_cast<FNCMapEntry*>(mMap.Add(aFileName.get(), fallible));
if (entry) {
entry->mFilename.Assign(aFileName);
entry->mTimestamp = aTimestamp;

View File

@ -557,8 +557,7 @@ XPCNativeScriptableSharedMap::GetNewOrUsed(uint32_t flags,
NS_PRECONDITION(si,"bad param");
XPCNativeScriptableShared key(flags, name);
Entry* entry = static_cast<Entry*>
(PL_DHashTableAdd(mTable, &key, fallible));
auto entry = static_cast<Entry*>(mTable->Add(&key, fallible));
if (!entry)
return false;

View File

@ -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<Entry*>
(PL_DHashTableAdd(mTable, obj, mozilla::fallible));
auto entry = static_cast<Entry*>(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<Entry*>
(PL_DHashTableAdd(mTable, iid, mozilla::fallible));
auto entry = static_cast<Entry*>(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<Entry*>
(PL_DHashTableAdd(mTable, iid, mozilla::fallible));
auto entry = static_cast<Entry*>(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<Entry*>
(PL_DHashTableAdd(mTable, info, mozilla::fallible));
auto entry = static_cast<Entry*>(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<Entry*>
(PL_DHashTableAdd(mTable, info, mozilla::fallible));
auto entry = static_cast<Entry*>(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<Entry*>
(PL_DHashTableAdd(mTable, key, mozilla::fallible));
auto entry = static_cast<Entry*>(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<Entry*>
(PL_DHashTableAdd(mTable, &iid, mozilla::fallible));
auto entry = static_cast<Entry*>(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<PLDHashEntryStub*>
(PL_DHashTableAdd(mTable, proto, mozilla::fallible));
auto entry = static_cast<PLDHashEntryStub*>
(mTable->Add(proto, mozilla::fallible));
if (!entry)
return nullptr;
if (entry->key)

View File

@ -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<PlaceholderMapEntry*>
(PL_DHashTableAdd(&mPlaceholderMap,
aPlaceholderFrame->GetOutOfFlowFrame(), fallible));
auto entry = static_cast<PlaceholderMapEntry*>
(mPlaceholderMap.Add(aPlaceholderFrame->GetOutOfFlowFrame(), fallible));
if (!entry)
return NS_ERROR_OUT_OF_MEMORY;

View File

@ -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<RuleHashTableEntry*>
(PL_DHashTableAdd(aTable, aKey, fallible));
auto entry = static_cast<RuleHashTableEntry*>(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<RuleHashTagTableEntry*>
(PL_DHashTableAdd(aTable, aKey, fallible));
auto entry = static_cast<RuleHashTagTableEntry*>(aTable->Add(aKey, fallible));
if (!entry)
return;
@ -1003,9 +1001,8 @@ RuleCascadeData::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
nsTArray<SelectorPair>*
RuleCascadeData::AttributeListFor(nsIAtom* aAttribute)
{
AtomSelectorEntry *entry =
static_cast<AtomSelectorEntry*>
(PL_DHashTableAdd(&mAttributeSelectors, aAttribute, fallible));
auto entry = static_cast<AtomSelectorEntry*>
(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<AtomSelectorEntry*>
(PL_DHashTableAdd(&aCascade->mIdSelectors, curID->mAtom, fallible));
auto entry = static_cast<AtomSelectorEntry*>
(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<AtomSelectorEntry*>
(PL_DHashTableAdd(&aCascade->mClassSelectors, curClass->mAtom,
fallible));
auto entry = static_cast<AtomSelectorEntry*>
(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<RuleByWeightEntry*>(
PL_DHashTableAdd(&data->mRulesByWeight, NS_INT32_TO_PTR(weight),
fallible));
auto entry = static_cast<RuleByWeightEntry*>
(data->mRulesByWeight.Add(NS_INT32_TO_PTR(weight), fallible));
if (!entry)
return false;
entry->data.mWeight = weight;

View File

@ -471,9 +471,8 @@ nsHTMLStyleSheet::SetVisitedLinkColor(nscolor aColor)
already_AddRefed<nsMappedAttributes>
nsHTMLStyleSheet::UniqueMappedAttributes(nsMappedAttributes* aMapped)
{
MappedAttrTableEntry *entry =
static_cast<MappedAttrTableEntry*>
(PL_DHashTableAdd(&mMappedAttrTable, aMapped, fallible));
auto entry = static_cast<MappedAttrTableEntry*>
(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<LangRuleTableEntry*>
(PL_DHashTableAdd(&mLangRuleTable, &aLanguage, fallible));
auto entry =
static_cast<LangRuleTableEntry*>(mLangRuleTable.Add(&aLanguage, fallible));
if (!entry) {
NS_ASSERTION(false, "out of memory");
return nullptr;

View File

@ -1539,8 +1539,8 @@ nsRuleNode::Transition(nsIStyleRule* aRule, uint8_t aLevel,
}
if (ChildrenAreHashed()) {
ChildrenHashEntry *entry = static_cast<ChildrenHashEntry*>
(PL_DHashTableAdd(ChildrenHash(), &key, fallible));
auto entry =
static_cast<ChildrenHashEntry*>(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<ChildrenHashEntry*>(
PL_DHashTableAdd(hash, curr->mRule, fallible));
auto entry =
static_cast<ChildrenHashEntry*>(hash->Add(curr->mRule, fallible));
NS_ASSERTION(!entry->mRuleNode, "duplicate entries in list");
entry->mRuleNode = curr;
}

View File

@ -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<HashTableEntry*>
(PL_DHashTableAdd(&mHashTable, NS_INT32_TO_PTR(aColSpan),
fallible));
auto entry = static_cast<HashTableEntry*>
(mHashTable.Add(NS_INT32_TO_PTR(aColSpan), fallible));
NS_ENSURE_TRUE(entry, false);
NS_ASSERTION(entry->mColSpan == 0 || entry->mColSpan == aColSpan,

View File

@ -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<PrefHashEntry*>
(PL_DHashTableAdd(gHashTable, key, fallible));
auto pref = static_cast<PrefHashEntry*>(gHashTable->Add(key, fallible));
if (!pref)
return NS_ERROR_OUT_OF_MEMORY;

View File

@ -491,9 +491,8 @@ nsLoadGroup::AddRequest(nsIRequest *request, nsISupports* ctxt)
// Add the request to the list of active requests...
//
RequestMapEntry *entry = static_cast<RequestMapEntry *>
(PL_DHashTableAdd(&mRequests, request, fallible));
auto entry =
static_cast<RequestMapEntry*>(mRequests.Add(request, fallible));
if (!entry) {
return NS_ERROR_OUT_OF_MEMORY;
}

View File

@ -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");

View File

@ -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<HashTableEntry*>
(table.Add((void*)(uintptr_t)binding->mRecord.HashNumber(), fallible));
if (!hashEntry)
return NS_ERROR_OUT_OF_MEMORY;
if (hashEntry->mBinding == nullptr) {
hashEntry->mBinding = binding;

View File

@ -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<nsHostDBEnt *>
(PL_DHashTableAdd(&mDB, &key, fallible));
auto he = static_cast<nsHostDBEnt*>(mDB.Add(&key, fallible));
// if the record is null, the hash table OOM'd.
if (!he) {

View File

@ -115,8 +115,8 @@ nsHttp::CreateAtomTable()
};
for (int i = 0; atoms[i]; ++i) {
PLDHashEntryStub *stub = reinterpret_cast<PLDHashEntryStub *>
(PL_DHashTableAdd(sAtomTable, atoms[i], fallible));
auto stub = static_cast<PLDHashEntryStub*>
(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<PLDHashEntryStub *>
(PL_DHashTableAdd(sAtomTable, str, fallible));
auto stub = static_cast<PLDHashEntryStub*>(sAtomTable->Add(str, fallible));
if (!stub)
return atom; // out of memory

View File

@ -92,9 +92,8 @@ nsHTMLEntities::AddRefTable(void)
node < node_end; ++node) {
// add to Entity->Unicode table
EntityNodeEntry* entry =
static_cast<EntityNodeEntry*>
(PL_DHashTableAdd(gEntityToUnicode, node->mStr, fallible));
auto entry = static_cast<EntityNodeEntry*>
(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<EntityNodeEntry*>
(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)

View File

@ -315,8 +315,8 @@ public:
void
SetForwardArcs(nsIRDFResource* u, Assertion* as) {
if (as) {
Entry* entry = static_cast<Entry*>
(PL_DHashTableAdd(&mForwardArcs, u, mozilla::fallible));
auto entry =
static_cast<Entry*>(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<Entry*>
(PL_DHashTableAdd(&mReverseArcs, v, mozilla::fallible));
auto entry =
static_cast<Entry*>(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<Entry*>(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<Entry*>(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<Entry*>(hdr);
entry->mNode = prop;

View File

@ -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;

View File

@ -186,8 +186,8 @@ CompareCacheHashEntry *
nsCertTree::getCacheEntry(void *cache, void *aCert)
{
PLDHashTable &aCompareCache = *reinterpret_cast<PLDHashTable*>(cache);
CompareCacheHashEntryPtr *entryPtr = static_cast<CompareCacheHashEntryPtr*>
(PL_DHashTableAdd(&aCompareCache, aCert, fallible));
auto entryPtr = static_cast<CompareCacheHashEntryPtr*>
(aCompareCache.Add(aCert, fallible));
return entryPtr ? entryPtr->entry : nullptr;
}

View File

@ -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)

View File

@ -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;
}

View File

@ -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;
}

View File

@ -917,8 +917,7 @@ CCGraph::AddNodeToMap(void* aPtr)
return nullptr;
}
PtrToNodeEntry* e = static_cast<PtrToNodeEntry*>
(PL_DHashTableAdd(&mPtrToNodeMap, aPtr, fallible));
auto e = static_cast<PtrToNodeEntry*>(mPtrToNodeMap.Add(aPtr, fallible));
if (!e) {
mOutOfMemory = true;
MOZ_ASSERT(false, "Ran out of memory while building cycle collector graph");

View File

@ -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<AtomTableEntry*>(PL_DHashTableAdd(gAtomTable, &key));
return static_cast<AtomTableEntry*>(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<AtomTableEntry*>(PL_DHashTableAdd(gAtomTable, &key));
return static_cast<AtomTableEntry*>(gAtomTable->Add(&key));
}
class CheckStaticAtomSizes

View File

@ -523,8 +523,8 @@ nsPersistentProperties::SetStringProperty(const nsACString& aKey,
nsAString& aOldValue)
{
const nsAFlatCString& flatKey = PromiseFlatCString(aKey);
PropertyTableEntry* entry = static_cast<PropertyTableEntry*>(
PL_DHashTableAdd(&mTable, flatKey.get(), mozilla::fallible));
auto entry = static_cast<PropertyTableEntry*>
(mTable.Add(flatKey.get(), mozilla::fallible));
if (entry->mKey) {
aOldValue = entry->mValue;

View File

@ -136,8 +136,7 @@ nsStaticCaseInsensitiveNameTable::nsStaticCaseInsensitiveNameTable(
NameTableKey key(strPtr);
NameTableEntry* entry = static_cast<NameTableEntry*>
(PL_DHashTableAdd(&mNameTable, &key, fallible));
auto entry = static_cast<NameTableEntry*>(mNameTable.Add(&key, fallible));
if (!entry) {
continue;
}

View File

@ -143,16 +143,15 @@ public:
*/
EntryType* PutEntry(KeyType aKey)
{
return static_cast<EntryType*> // infallible add
(PL_DHashTableAdd(&mTable, EntryType::KeyToPointer(aKey)));
// infallible add
return static_cast<EntryType*>(mTable.Add(EntryType::KeyToPointer(aKey)));
}
MOZ_WARN_UNUSED_RESULT
EntryType* PutEntry(KeyType aKey, const fallible_t&)
{
return static_cast<EntryType*>
(PL_DHashTableAdd(&mTable, EntryType::KeyToPointer(aKey),
mozilla::fallible));
return static_cast<EntryType*>(mTable.Add(EntryType::KeyToPointer(aKey),
mozilla::fallible));
}
/**

View File

@ -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)
{

View File

@ -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);

View File

@ -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++;