Bug 1121760 (part 1) - Remove PL_DHashTableSearch(). r=poiru.

This commit is contained in:
Nicholas Nethercote 2015-05-21 00:34:25 -07:00
parent 43c97cd2fc
commit ba83ffc5ec
30 changed files with 120 additions and 194 deletions

View File

@ -4122,9 +4122,8 @@ nsContentUtils::TraverseListenerManager(nsINode *aNode,
return;
}
EventListenerManagerMapEntry *entry =
static_cast<EventListenerManagerMapEntry *>
(PL_DHashTableSearch(sEventListenerManagersHash, aNode));
auto entry = static_cast<EventListenerManagerMapEntry*>
(sEventListenerManagersHash->Search(aNode));
if (entry) {
CycleCollectionNoteChild(cb, entry->mListenerManager.get(),
"[via hash] mListenerManager");
@ -4172,9 +4171,8 @@ nsContentUtils::GetExistingListenerManagerForNode(const nsINode *aNode)
return nullptr;
}
EventListenerManagerMapEntry *entry =
static_cast<EventListenerManagerMapEntry *>
(PL_DHashTableSearch(sEventListenerManagersHash, aNode));
auto entry = static_cast<EventListenerManagerMapEntry*>
(sEventListenerManagersHash->Search(aNode));
if (entry) {
return entry->mListenerManager;
}
@ -4187,9 +4185,8 @@ void
nsContentUtils::RemoveListenerManager(nsINode *aNode)
{
if (sEventListenerManagersHash) {
EventListenerManagerMapEntry *entry =
static_cast<EventListenerManagerMapEntry *>
(PL_DHashTableSearch(sEventListenerManagersHash, aNode));
auto entry = static_cast<EventListenerManagerMapEntry*>
(sEventListenerManagersHash->Search(aNode));
if (entry) {
nsRefPtr<EventListenerManager> listenerManager;
listenerManager.swap(entry->mListenerManager);

View File

@ -3994,9 +3994,8 @@ nsIDocument*
nsDocument::GetSubDocumentFor(nsIContent *aContent) const
{
if (mSubDocuments && aContent->IsElement()) {
SubDocMapEntry *entry =
static_cast<SubDocMapEntry*>
(PL_DHashTableSearch(mSubDocuments, aContent->AsElement()));
auto entry = static_cast<SubDocMapEntry*>
(mSubDocuments->Search(aContent->AsElement()));
if (entry) {
return entry->mSubDocument;

View File

@ -93,9 +93,8 @@ nsPropertyTable::TransferOrDeleteAllPropertiesFor(nsPropertyOwner aObject,
nsresult rv = NS_OK;
for (PropertyList* prop = mPropertyList; prop; prop = prop->mNext) {
if (prop->mTransfer) {
PropertyListMapEntry *entry =
static_cast<PropertyListMapEntry*>
(PL_DHashTableSearch(&prop->mObjectValueMap, aObject));
auto entry = static_cast<PropertyListMapEntry*>
(prop->mObjectValueMap.Search(aObject));
if (entry) {
rv = aOtherTable->SetProperty(aObject, prop->mName,
entry->value, prop->mDtorFunc,
@ -124,8 +123,8 @@ nsPropertyTable::Enumerate(nsPropertyOwner aObject,
{
PropertyList* prop;
for (prop = mPropertyList; prop; prop = prop->mNext) {
PropertyListMapEntry *entry = static_cast<PropertyListMapEntry*>
(PL_DHashTableSearch(&prop->mObjectValueMap, aObject));
auto entry = static_cast<PropertyListMapEntry*>
(prop->mObjectValueMap.Search(aObject));
if (entry) {
aCallback(const_cast<void*>(aObject.get()), prop->mName, entry->value,
aData);
@ -157,9 +156,8 @@ nsPropertyTable::GetPropertyInternal(nsPropertyOwner aObject,
PropertyList* propertyList = GetPropertyListFor(aPropertyName);
if (propertyList) {
PropertyListMapEntry *entry =
static_cast<PropertyListMapEntry*>
(PL_DHashTableSearch(&propertyList->mObjectValueMap, aObject));
auto entry = static_cast<PropertyListMapEntry*>
(propertyList->mObjectValueMap.Search(aObject));
if (entry) {
propValue = entry->value;
if (aRemove) {
@ -294,9 +292,8 @@ nsPropertyTable::PropertyList::Destroy()
bool
nsPropertyTable::PropertyList::DeletePropertyFor(nsPropertyOwner aObject)
{
PropertyListMapEntry *entry =
static_cast<PropertyListMapEntry*>
(PL_DHashTableSearch(&mObjectValueMap, aObject));
auto entry =
static_cast<PropertyListMapEntry*>(mObjectValueMap.Search(aObject));
if (!entry)
return false;

View File

@ -159,10 +159,8 @@ nsScriptNameSpaceManager::GetConstructorProto(const nsGlobalNameStruct* aStruct)
NS_ASSERTION(aStruct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias,
"This function only works on constructor aliases!");
if (!aStruct->mAlias->mProto) {
GlobalNameMapEntry *proto =
static_cast<GlobalNameMapEntry *>
(PL_DHashTableSearch(&mGlobalNames,
&aStruct->mAlias->mProtoName));
auto proto = static_cast<GlobalNameMapEntry*>
(mGlobalNames.Search(&aStruct->mAlias->mProtoName));
if (proto) {
aStruct->mAlias->mProto = &proto->mGlobalName;
}
@ -344,9 +342,7 @@ nsGlobalNameStruct*
nsScriptNameSpaceManager::LookupNameInternal(const nsAString& aName,
const char16_t **aClassName)
{
GlobalNameMapEntry *entry =
static_cast<GlobalNameMapEntry *>
(PL_DHashTableSearch(&mGlobalNames, &aName));
auto entry = static_cast<GlobalNameMapEntry*>(mGlobalNames.Search(&aName));
if (entry) {
if (aClassName) {
@ -364,9 +360,7 @@ nsScriptNameSpaceManager::LookupNameInternal(const nsAString& aName,
const nsGlobalNameStruct*
nsScriptNameSpaceManager::LookupNavigatorName(const nsAString& aName)
{
GlobalNameMapEntry *entry =
static_cast<GlobalNameMapEntry *>
(PL_DHashTableSearch(&mNavigatorNames, &aName));
auto entry = static_cast<GlobalNameMapEntry*>(mNavigatorNames.Search(&aName));
return entry ? &entry->mGlobalName : nullptr;
}

View File

@ -1779,11 +1779,11 @@ NPObjWrapper_ObjectMoved(JSObject *obj, const JSObject *old)
return;
}
// Calling PL_DHashTableSearch() will not result in GC.
// Calling PLDHashTable::Search() will not result in GC.
JS::AutoSuppressGCAnalysis nogc;
NPObjWrapperHashEntry *entry = static_cast<NPObjWrapperHashEntry *>
(PL_DHashTableSearch(sNPObjWrappers, npobj));
auto entry =
static_cast<NPObjWrapperHashEntry*>(sNPObjWrappers->Search(npobj));
MOZ_ASSERT(entry && entry->mJSObj);
MOZ_ASSERT(entry->mJSObj == old);
entry->mJSObj = obj;
@ -1835,8 +1835,8 @@ nsNPObjWrapper::OnDestroy(NPObject *npobj)
return;
}
NPObjWrapperHashEntry *entry = static_cast<NPObjWrapperHashEntry *>
(PL_DHashTableSearch(sNPObjWrappers, npobj));
auto entry =
static_cast<NPObjWrapperHashEntry*>(sNPObjWrappers->Search(npobj));
if (entry && entry->mJSObj) {
// Found a live NPObject wrapper, null out its JSObjects' private
@ -1919,7 +1919,7 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, NPObject *npobj)
// Reload entry if the JS_NewObject call caused a GC and reallocated
// the table (see bug 445229). This is guaranteed to succeed.
NS_ASSERTION(PL_DHashTableSearch(sNPObjWrappers, npobj),
NS_ASSERTION(sNPObjWrappers->Search(npobj),
"Hashtable didn't find what we just added?");
}

View File

@ -763,10 +763,8 @@ XULDocument::AddBroadcastListenerFor(Element& aBroadcaster, Element& aListener,
mBroadcasterMap = new PLDHashTable(&gOps, sizeof(BroadcasterMapEntry));
}
BroadcasterMapEntry* entry =
static_cast<BroadcasterMapEntry*>
(PL_DHashTableSearch(mBroadcasterMap, &aBroadcaster));
auto entry = static_cast<BroadcasterMapEntry*>
(mBroadcasterMap->Search(&aBroadcaster));
if (!entry) {
entry = static_cast<BroadcasterMapEntry*>
(PL_DHashTableAdd(mBroadcasterMap, &aBroadcaster, fallible));
@ -824,10 +822,8 @@ XULDocument::RemoveBroadcastListenerFor(Element& aBroadcaster,
if (! mBroadcasterMap)
return;
BroadcasterMapEntry* entry =
static_cast<BroadcasterMapEntry*>
(PL_DHashTableSearch(mBroadcasterMap, &aBroadcaster));
auto entry = static_cast<BroadcasterMapEntry*>
(mBroadcasterMap->Search(&aBroadcaster));
if (entry) {
nsCOMPtr<nsIAtom> attr = do_GetAtom(aAttr);
for (size_t i = entry->mListeners.Length() - 1; i != (size_t)-1; --i) {
@ -944,9 +940,8 @@ XULDocument::AttributeChanged(nsIDocument* aDocument,
// Synchronize broadcast listeners
if (mBroadcasterMap &&
CanBroadcast(aNameSpaceID, aAttribute)) {
BroadcasterMapEntry* entry =
static_cast<BroadcasterMapEntry*>
(PL_DHashTableSearch(mBroadcasterMap, aElement));
auto entry = static_cast<BroadcasterMapEntry*>
(mBroadcasterMap->Search(aElement));
if (entry) {
// We've got listeners: push the value.
@ -4106,8 +4101,8 @@ XULDocument::BroadcastAttributeChangeFromOverlay(nsIContent* aNode,
if (!aNode->IsElement())
return rv;
BroadcasterMapEntry* entry = static_cast<BroadcasterMapEntry*>
(PL_DHashTableSearch(mBroadcasterMap, aNode->AsElement()));
auto entry = static_cast<BroadcasterMapEntry*>
(mBroadcasterMap->Search(aNode->AsElement()));
if (!entry)
return rv;

View File

@ -38,7 +38,7 @@ public:
}
bool Get(nsIContent* aElement, nsTemplateMatch** aMatch) {
PLDHashEntryHdr* hdr = PL_DHashTableSearch(&mMap, aElement);
PLDHashEntryHdr* hdr = mMap.Search(aElement);
if (!hdr)
return false;

View File

@ -25,8 +25,7 @@ public:
void
Put(nsIContent* aContent, nsIContent* aTemplate) {
NS_ASSERTION(!PL_DHashTableSearch(&mTable, aContent),
"aContent already in map");
NS_ASSERTION(!mTable.Search(aContent), "aContent already in map");
Entry* entry = static_cast<Entry*>
(PL_DHashTableAdd(&mTable, aContent, fallible));
@ -51,9 +50,7 @@ public:
void
GetTemplateFor(nsIContent* aContent, nsIContent** aResult) {
Entry* entry =
static_cast<Entry*>(PL_DHashTableSearch(&mTable, aContent));
auto entry = static_cast<Entry*>(mTable.Search(aContent));
if (entry)
NS_IF_ADDREF(*aResult = entry->mTemplate);
else

View File

@ -207,14 +207,13 @@ nsCommandParams::RemoveValue(const char* aName)
nsCommandParams::HashEntry*
nsCommandParams::GetNamedEntry(const char* aName)
{
return (HashEntry*)PL_DHashTableSearch(&mValuesHash, (void*)aName);
return static_cast<HashEntry*>(mValuesHash.Search((void*)aName));
}
nsCommandParams::HashEntry*
nsCommandParams::GetOrMakeEntry(const char* aName, uint8_t aEntryType)
{
HashEntry* foundEntry =
(HashEntry*)PL_DHashTableSearch(&mValuesHash, (void*)aName);
auto foundEntry = static_cast<HashEntry*>(mValuesHash.Search((void*)aName));
if (foundEntry) { // reuse existing entry
foundEntry->Reset(aEntryType);
return foundEntry;

View File

@ -724,9 +724,7 @@ public:
GetInfoForFile(const nsCString& aFileName, nsCString& aFaceList,
uint32_t *aTimestamp, uint32_t *aFilesize)
{
FNCMapEntry *entry =
static_cast<FNCMapEntry*>(PL_DHashTableSearch(&mMap,
aFileName.get()));
auto entry = static_cast<FNCMapEntry*>(mMap.Search(aFileName.get()));
if (entry) {
*aTimestamp = entry->mTimestamp;
*aFilesize = entry->mFilesize;

View File

@ -114,7 +114,7 @@ public:
inline XPCWrappedNative* Find(nsISupports* Obj)
{
NS_PRECONDITION(Obj,"bad param");
Entry* entry = (Entry*) PL_DHashTableSearch(mTable, Obj);
auto entry = static_cast<Entry*>(mTable->Search(Obj));
return entry ? entry->value : nullptr;
}
@ -178,7 +178,7 @@ public:
inline nsXPCWrappedJSClass* Find(REFNSIID iid)
{
Entry* entry = (Entry*) PL_DHashTableSearch(mTable, &iid);
auto entry = static_cast<Entry*>(mTable->Search(&iid));
return entry ? entry->value : nullptr;
}
@ -232,7 +232,7 @@ public:
inline XPCNativeInterface* Find(REFNSIID iid)
{
Entry* entry = (Entry*) PL_DHashTableSearch(mTable, &iid);
auto entry = static_cast<Entry*>(mTable->Search(&iid));
return entry ? entry->value : nullptr;
}
@ -287,7 +287,7 @@ public:
inline XPCNativeSet* Find(nsIClassInfo* info)
{
Entry* entry = (Entry*) PL_DHashTableSearch(mTable, info);
auto entry = static_cast<Entry*>(mTable->Search(info));
return entry ? entry->value : nullptr;
}
@ -344,7 +344,7 @@ public:
inline XPCWrappedNativeProto* Find(nsIClassInfo* info)
{
Entry* entry = (Entry*) PL_DHashTableSearch(mTable, info);
auto entry = static_cast<Entry*>(mTable->Search(info));
return entry ? entry->value : nullptr;
}
@ -405,7 +405,7 @@ public:
inline XPCNativeSet* Find(XPCNativeSetKey* key)
{
Entry* entry = (Entry*) PL_DHashTableSearch(mTable, key);
auto entry = static_cast<Entry*>(mTable->Search(key));
return entry ? entry->key_value : nullptr;
}
@ -478,7 +478,7 @@ public:
inline nsIXPCFunctionThisTranslator* Find(REFNSIID iid)
{
Entry* entry = (Entry*) PL_DHashTableSearch(mTable, &iid);
auto entry = static_cast<Entry*>(mTable->Search(&iid));
return entry ? entry->value : nullptr;
}

View File

@ -164,9 +164,8 @@ nsFrameManager::GetPlaceholderFrameFor(const nsIFrame* aFrame)
{
NS_PRECONDITION(aFrame, "null param unexpected");
PlaceholderMapEntry *entry = static_cast<PlaceholderMapEntry*>
(PL_DHashTableSearch(const_cast<PLDHashTable*>(&mPlaceholderMap),
aFrame));
auto entry = static_cast<PlaceholderMapEntry*>
(const_cast<PLDHashTable*>(&mPlaceholderMap)->Search(aFrame));
if (entry) {
return entry->placeholderFrame;
}

View File

@ -672,24 +672,22 @@ void RuleHash::EnumerateAllRules(Element* aElement, ElementDependentRuleProcesso
}
// universal rules within the namespace
if (kNameSpaceID_Unknown != nameSpace && mNameSpaceTable.EntryCount() > 0) {
RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
(PL_DHashTableSearch(&mNameSpaceTable, NS_INT32_TO_PTR(nameSpace)));
auto entry = static_cast<RuleHashTableEntry*>
(mNameSpaceTable.Search(NS_INT32_TO_PTR(nameSpace)));
if (entry) {
mEnumList[valueCount++] = ToEnumData(entry->mRules);
RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementNameSpaceCalls);
}
}
if (mTagTable.EntryCount() > 0) {
RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
(PL_DHashTableSearch(&mTagTable, tag));
auto entry = static_cast<RuleHashTableEntry*>(mTagTable.Search(tag));
if (entry) {
mEnumList[valueCount++] = ToEnumData(entry->mRules);
RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementTagCalls);
}
}
if (id && mIdTable.EntryCount() > 0) {
RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
(PL_DHashTableSearch(&mIdTable, id));
auto entry = static_cast<RuleHashTableEntry*>(mIdTable.Search(id));
if (entry) {
mEnumList[valueCount++] = ToEnumData(entry->mRules);
RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementIdCalls);
@ -697,8 +695,8 @@ void RuleHash::EnumerateAllRules(Element* aElement, ElementDependentRuleProcesso
}
if (mClassTable.EntryCount() > 0) {
for (int32_t index = 0; index < classCount; ++index) {
RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
(PL_DHashTableSearch(&mClassTable, classList->AtomAt(index)));
auto entry = static_cast<RuleHashTableEntry*>
(mClassTable.Search(classList->AtomAt(index)));
if (entry) {
mEnumList[valueCount++] = ToEnumData(entry->mRules);
RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementClassCalls);
@ -2644,8 +2642,8 @@ nsCSSRuleProcessor::RulesMatching(AnonBoxRuleProcessorData* aData)
RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
if (cascade && cascade->mAnonBoxRules.EntryCount()) {
RuleHashTagTableEntry* entry = static_cast<RuleHashTagTableEntry*>
(PL_DHashTableSearch(&cascade->mAnonBoxRules, aData->mPseudoTag));
auto entry = static_cast<RuleHashTagTableEntry*>
(cascade->mAnonBoxRules.Search(aData->mPseudoTag));
if (entry) {
nsTArray<RuleValue>& rules = entry->mRules;
for (RuleValue *value = rules.Elements(), *end = value + rules.Length();
@ -2664,8 +2662,8 @@ nsCSSRuleProcessor::RulesMatching(XULTreeRuleProcessorData* aData)
RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
if (cascade && cascade->mXULTreeRules.EntryCount()) {
RuleHashTagTableEntry* entry = static_cast<RuleHashTagTableEntry*>
(PL_DHashTableSearch(&cascade->mXULTreeRules, aData->mPseudoTag));
auto entry = static_cast<RuleHashTagTableEntry*>
(cascade->mXULTreeRules.Search(aData->mPseudoTag));
if (entry) {
NodeMatchContext nodeContext(EventStates(),
nsCSSRuleProcessor::IsLink(aData->mElement));
@ -2984,9 +2982,8 @@ nsCSSRuleProcessor::HasAttributeDependentStyle(
if (aData->mAttribute == nsGkAtoms::id) {
nsIAtom* id = aData->mElement->GetID();
if (id) {
AtomSelectorEntry *entry =
static_cast<AtomSelectorEntry*>
(PL_DHashTableSearch(&cascade->mIdSelectors, id));
auto entry =
static_cast<AtomSelectorEntry*>(cascade->mIdSelectors.Search(id));
if (entry) {
EnumerateSelectors(entry->mSelectors, &data);
}
@ -3021,10 +3018,9 @@ nsCSSRuleProcessor::HasAttributeDependentStyle(
for (int32_t i = 0; i < atomCount; ++i) {
nsIAtom* curClass = elementClasses->AtomAt(i);
if (!otherClassesTable.Contains(curClass)) {
AtomSelectorEntry *entry =
auto entry =
static_cast<AtomSelectorEntry*>
(PL_DHashTableSearch(&cascade->mClassSelectors,
curClass));
(cascade->mClassSelectors.Search(curClass));
if (entry) {
EnumerateSelectors(entry->mSelectors, &data);
}
@ -3036,10 +3032,9 @@ nsCSSRuleProcessor::HasAttributeDependentStyle(
EnumerateSelectors(cascade->mPossiblyNegatedClassSelectors, &data);
}
AtomSelectorEntry *entry =
auto entry =
static_cast<AtomSelectorEntry*>
(PL_DHashTableSearch(&cascade->mAttributeSelectors,
aData->mAttribute));
(cascade->mAttributeSelectors.Search(aData->mAttribute));
if (entry) {
EnumerateSelectors(entry->mSelectors, &data);
}

View File

@ -698,7 +698,7 @@ PrefHashEntry* pref_HashTableLookup(const char *key)
MOZ_ASSERT(NS_IsMainThread());
#endif
return static_cast<PrefHashEntry*>(PL_DHashTableSearch(gHashTable, key));
return static_cast<PrefHashEntry*>(gHashTable->Search(key));
}
nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, uint32_t flags)

View File

@ -255,7 +255,7 @@ nsLoadGroup::Cancel(nsresult status)
NS_ASSERTION(request, "NULL request found in list.");
if (!PL_DHashTableSearch(&mRequests, request)) {
if (!mRequests.Search(request)) {
// |request| was removed already
NS_RELEASE(request);
continue;
@ -463,7 +463,7 @@ nsLoadGroup::AddRequest(nsIRequest *request, nsISupports* ctxt)
this, request, nameStr.get(), mRequests.EntryCount()));
}
NS_ASSERTION(!PL_DHashTableSearch(&mRequests, request),
NS_ASSERTION(!mRequests.Search(request),
"Entry added to loadgroup twice, don't do that");
//
@ -571,9 +571,7 @@ nsLoadGroup::RemoveRequest(nsIRequest *request, nsISupports* ctxt,
// the request was *not* in the group so do not update the foreground
// count or it will get messed up...
//
RequestMapEntry *entry =
static_cast<RequestMapEntry *>
(PL_DHashTableSearch(&mRequests, request));
auto entry = static_cast<RequestMapEntry*>(mRequests.Search(request));
if (!entry) {
LOG(("LOADGROUP [%x]: Unable to remove request %x. Not in group!\n",

View File

@ -420,7 +420,7 @@ nsCacheEntryHashTable::GetEntry( const nsCString * key)
NS_ASSERTION(initialized, "nsCacheEntryHashTable not initialized");
if (!initialized) return nullptr;
PLDHashEntryHdr *hashEntry = PL_DHashTableSearch(&table, key);
PLDHashEntryHdr *hashEntry = table.Search(key);
return hashEntry ? ((nsCacheEntryHashTableEntry *)hashEntry)->cacheEntry
: nullptr;
}

View File

@ -197,10 +197,8 @@ nsDiskCacheBindery::FindActiveBinding(uint32_t hashNumber)
{
NS_ASSERTION(initialized, "nsDiskCacheBindery not initialized");
// find hash entry for key
HashTableEntry * hashEntry;
hashEntry =
(HashTableEntry *) PL_DHashTableSearch(&table,
(void*)(uintptr_t) hashNumber);
auto hashEntry = static_cast<HashTableEntry*>
(table.Search((void*)(uintptr_t)hashNumber));
if (!hashEntry) return nullptr;
// walk list looking for active entry
@ -294,11 +292,9 @@ nsDiskCacheBindery::RemoveBinding(nsDiskCacheBinding * binding)
NS_ASSERTION(initialized, "nsDiskCacheBindery not initialized");
if (!initialized) return;
HashTableEntry * hashEntry;
void * key = (void *)(uintptr_t)binding->mRecord.HashNumber();
hashEntry = (HashTableEntry*) PL_DHashTableSearch(&table,
(void*)(uintptr_t) key);
void* key = (void *)(uintptr_t)binding->mRecord.HashNumber();
auto hashEntry =
static_cast<HashTableEntry*>(table.Search((void*)(uintptr_t) key));
if (!hashEntry) {
NS_WARNING("### disk cache: binding not in hashtable!");
return;

View File

@ -838,8 +838,8 @@ nsHostResolver::ResolveHost(const char *host,
// First, search for an entry with AF_UNSPEC
const nsHostKey unspecKey = { host, flags, PR_AF_UNSPEC,
netInterface };
nsHostDBEnt *unspecHe = static_cast<nsHostDBEnt *>
(PL_DHashTableSearch(&mDB, &unspecKey));
auto unspecHe =
static_cast<nsHostDBEnt*>(mDB.Search(&unspecKey));
NS_ASSERTION(!unspecHe ||
(unspecHe && unspecHe->rec),
"Valid host entries should contain a record");
@ -977,8 +977,7 @@ nsHostResolver::DetachCallback(const char *host,
MutexAutoLock lock(mLock);
nsHostKey key = { host, flags, af, netInterface };
nsHostDBEnt *he = static_cast<nsHostDBEnt *>
(PL_DHashTableSearch(&mDB, &key));
auto he = static_cast<nsHostDBEnt*>(mDB.Search(&key));
if (he) {
// walk list looking for |callback|... we cannot assume
// that it will be there!
@ -1323,8 +1322,7 @@ nsHostResolver::CancelAsyncRequest(const char *host,
// Lookup the host record associated with host, flags & address family
nsHostKey key = { host, flags, af, netInterface };
nsHostDBEnt *he = static_cast<nsHostDBEnt *>
(PL_DHashTableSearch(&mDB, &key));
auto he = static_cast<nsHostDBEnt*>(mDB.Search(&key));
if (he) {
nsHostRecord* recPtr = nullptr;
PRCList *node = he->rec->callbacks.next;

View File

@ -147,9 +147,8 @@ nsHTMLEntities::EntityToUnicode(const nsCString& aEntity)
return EntityToUnicode(temp);
}
EntityNodeEntry* entry =
static_cast<EntityNodeEntry*>
(PL_DHashTableSearch(gEntityToUnicode, aEntity.get()));
auto entry =
static_cast<EntityNodeEntry*>(gEntityToUnicode->Search(aEntity.get()));
return entry ? entry->node->mUnicode : -1;
}
@ -170,9 +169,9 @@ const char*
nsHTMLEntities::UnicodeToEntity(int32_t aUnicode)
{
NS_ASSERTION(gUnicodeToEntity, "no lookup table, needs addref");
EntityNodeEntry* entry =
auto entry =
static_cast<EntityNodeEntry*>
(PL_DHashTableSearch(gUnicodeToEntity, NS_INT32_TO_PTR(aUnicode)));
(gUnicodeToEntity->Search(NS_INT32_TO_PTR(aUnicode)));
return entry ? entry->node->mStr : nullptr;
}

View File

@ -302,13 +302,13 @@ public:
// Implementation methods
Assertion*
GetForwardArcs(nsIRDFResource* u) {
PLDHashEntryHdr* hdr = PL_DHashTableSearch(&mForwardArcs, u);
PLDHashEntryHdr* hdr = mForwardArcs.Search(u);
return hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
}
Assertion*
GetReverseArcs(nsIRDFNode* v) {
PLDHashEntryHdr* hdr = PL_DHashTableSearch(&mReverseArcs, v);
PLDHashEntryHdr* hdr = mReverseArcs.Search(v);
return hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
}
@ -421,8 +421,7 @@ InMemoryAssertionEnumeratorImpl::InMemoryAssertionEnumeratorImpl(
if (mNextAssertion && mNextAssertion->mHashEntry) {
// its our magical HASH_ENTRY forward hash for assertions
PLDHashEntryHdr* hdr =
PL_DHashTableSearch(mNextAssertion->u.hash.mPropertyHash,
aProperty);
mNextAssertion->u.hash.mPropertyHash->Search(aProperty);
mNextAssertion =
hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
}
@ -917,8 +916,7 @@ InMemoryDataSource::GetTarget(nsIRDFResource* source,
Assertion *as = GetForwardArcs(source);
if (as && as->mHashEntry) {
PLDHashEntryHdr* hdr =
PL_DHashTableSearch(as->u.hash.mPropertyHash, property);
PLDHashEntryHdr* hdr = as->u.hash.mPropertyHash->Search(property);
Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
while (val) {
if (tv == val->u.as.mTruthValue) {
@ -962,8 +960,7 @@ InMemoryDataSource::HasAssertion(nsIRDFResource* source,
Assertion *as = GetForwardArcs(source);
if (as && as->mHashEntry) {
PLDHashEntryHdr* hdr =
PL_DHashTableSearch(as->u.hash.mPropertyHash, property);
PLDHashEntryHdr* hdr = as->u.hash.mPropertyHash->Search(property);
Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
while (val) {
if ((val->u.as.mTarget == target) && (tv == (val->u.as.mTruthValue))) {
@ -1072,8 +1069,7 @@ InMemoryDataSource::LockedAssert(nsIRDFResource* aSource,
bool haveHash = (next) ? next->mHashEntry : false;
if (haveHash) {
PLDHashEntryHdr* hdr =
PL_DHashTableSearch(next->u.hash.mPropertyHash, aProperty);
PLDHashEntryHdr* hdr = next->u.hash.mPropertyHash->Search(aProperty);
Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
while (val) {
if (val->u.as.mTarget == aTarget) {
@ -1112,8 +1108,7 @@ InMemoryDataSource::LockedAssert(nsIRDFResource* aSource,
if (haveHash)
{
PLDHashEntryHdr* hdr =
PL_DHashTableSearch(next->u.hash.mPropertyHash, aProperty);
PLDHashEntryHdr* hdr = next->u.hash.mPropertyHash->Search(aProperty);
Assertion *asRef =
hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
if (asRef)
@ -1211,8 +1206,7 @@ InMemoryDataSource::LockedUnassert(nsIRDFResource* aSource,
bool haveHash = (next) ? next->mHashEntry : false;
if (haveHash) {
PLDHashEntryHdr* hdr =
PL_DHashTableSearch(next->u.hash.mPropertyHash, aProperty);
PLDHashEntryHdr* hdr = next->u.hash.mPropertyHash->Search(aProperty);
prev = next = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
bool first = true;
while (next) {
@ -1513,8 +1507,7 @@ InMemoryDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, boo
{
Assertion* ass = GetForwardArcs(aSource);
if (ass && ass->mHashEntry) {
PLDHashEntryHdr* hdr =
PL_DHashTableSearch(ass->u.hash.mPropertyHash, aArc);
PLDHashEntryHdr* hdr = ass->u.hash.mPropertyHash->Search(aArc);
Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
if (val) {
*result = true;
@ -1664,7 +1657,7 @@ InMemoryDataSource::EnsureFastContainment(nsIRDFResource* aSource)
nextRef = first->mNext;
nsIRDFResource *prop = first->u.as.mProperty;
PLDHashEntryHdr* hdr = PL_DHashTableSearch(table, prop);
PLDHashEntryHdr* hdr = table->Search(prop);
Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
if (val) {
first->mNext = val->mNext;
@ -1727,8 +1720,7 @@ InMemoryDataSource::Mark(nsIRDFResource* aSource,
Assertion *as = GetForwardArcs(aSource);
if (as && as->mHashEntry) {
PLDHashEntryHdr* hdr =
PL_DHashTableSearch(as->u.hash.mPropertyHash, aProperty);
PLDHashEntryHdr* hdr = as->u.hash.mPropertyHash->Search(aProperty);
Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
while (val) {
if ((val->u.as.mTarget == aTarget) &&
@ -1844,7 +1836,7 @@ InMemoryDataSource::SweepForwardArcsEntries(PLDHashTable* aTable,
// remove from the reverse arcs
PLDHashEntryHdr* hdr =
PL_DHashTableSearch(aInfo->mReverseArcs, as->u.as.mTarget);
aInfo->mReverseArcs->Search(as->u.as.mTarget);
NS_ASSERTION(hdr, "no assertion in reverse arcs");
Entry* rentry = static_cast<Entry*>(hdr);

View File

@ -839,7 +839,7 @@ RDFServiceImpl::GetResource(const nsACString& aURI, nsIRDFResource** aResource)
// First, check the cache to see if we've already created and
// registered this thing.
PLDHashEntryHdr *hdr = PL_DHashTableSearch(&mResources, flatURI.get());
PLDHashEntryHdr *hdr = mResources.Search(flatURI.get());
if (hdr) {
ResourceHashEntry *entry = static_cast<ResourceHashEntry *>(hdr);
NS_ADDREF(*aResource = entry->mResource);
@ -1007,7 +1007,7 @@ RDFServiceImpl::GetLiteral(const char16_t* aValue, nsIRDFLiteral** aLiteral)
return NS_ERROR_NULL_POINTER;
// See if we have one already cached
PLDHashEntryHdr *hdr = PL_DHashTableSearch(&mLiterals, aValue);
PLDHashEntryHdr *hdr = mLiterals.Search(aValue);
if (hdr) {
LiteralHashEntry *entry = static_cast<LiteralHashEntry *>(hdr);
NS_ADDREF(*aLiteral = entry->mLiteral);
@ -1022,7 +1022,7 @@ NS_IMETHODIMP
RDFServiceImpl::GetDateLiteral(PRTime aTime, nsIRDFDate** aResult)
{
// See if we have one already cached
PLDHashEntryHdr *hdr = PL_DHashTableSearch(&mDates, &aTime);
PLDHashEntryHdr *hdr = mDates.Search(&aTime);
if (hdr) {
DateHashEntry *entry = static_cast<DateHashEntry *>(hdr);
NS_ADDREF(*aResult = entry->mDate);
@ -1041,7 +1041,7 @@ NS_IMETHODIMP
RDFServiceImpl::GetIntLiteral(int32_t aInt, nsIRDFInt** aResult)
{
// See if we have one already cached
PLDHashEntryHdr *hdr = PL_DHashTableSearch(&mInts, &aInt);
PLDHashEntryHdr *hdr = mInts.Search(&aInt);
if (hdr) {
IntHashEntry *entry = static_cast<IntHashEntry *>(hdr);
NS_ADDREF(*aResult = entry->mInt);
@ -1062,7 +1062,7 @@ RDFServiceImpl::GetBlobLiteral(const uint8_t *aBytes, int32_t aLength,
{
BlobImpl::Data key = { aLength, const_cast<uint8_t *>(aBytes) };
PLDHashEntryHdr *hdr = PL_DHashTableSearch(&mBlobs, &key);
PLDHashEntryHdr *hdr = mBlobs.Search(&key);
if (hdr) {
BlobHashEntry *entry = static_cast<BlobHashEntry *>(hdr);
NS_ADDREF(*aResult = entry->mBlob);
@ -1123,7 +1123,7 @@ RDFServiceImpl::RegisterResource(nsIRDFResource* aResource, bool aReplace)
if (! uri)
return NS_ERROR_NULL_POINTER;
PLDHashEntryHdr *hdr = PL_DHashTableSearch(&mResources, uri);
PLDHashEntryHdr *hdr = mResources.Search(uri);
if (hdr) {
if (!aReplace) {
NS_WARNING("resource already registered, and replace not specified");
@ -1182,7 +1182,7 @@ RDFServiceImpl::UnregisterResource(nsIRDFResource* aResource)
aResource, (const char*) uri));
#ifdef DEBUG
if (!PL_DHashTableSearch(&mResources, uri))
if (!mResources.Search(uri))
NS_WARNING("resource was never registered");
#endif
@ -1374,8 +1374,7 @@ RDFServiceImpl::RegisterLiteral(nsIRDFLiteral* aLiteral)
const char16_t* value;
aLiteral->GetValueConst(&value);
NS_ASSERTION(!PL_DHashTableSearch(&mLiterals, value),
"literal already registered");
NS_ASSERTION(!mLiterals.Search(value), "literal already registered");
PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mLiterals, value, fallible);
if (! hdr)
@ -1404,8 +1403,7 @@ RDFServiceImpl::UnregisterLiteral(nsIRDFLiteral* aLiteral)
const char16_t* value;
aLiteral->GetValueConst(&value);
NS_ASSERTION(PL_DHashTableSearch(&mLiterals, value),
"literal was never registered");
NS_ASSERTION(mLiterals.Search(value), "literal was never registered");
PL_DHashTableRemove(&mLiterals, value);
@ -1426,8 +1424,7 @@ RDFServiceImpl::RegisterInt(nsIRDFInt* aInt)
int32_t value;
aInt->GetValue(&value);
NS_ASSERTION(!PL_DHashTableSearch(&mInts, &value),
"int already registered");
NS_ASSERTION(!mInts.Search(&value), "int already registered");
PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mInts, &value, fallible);
if (! hdr)
@ -1456,8 +1453,7 @@ RDFServiceImpl::UnregisterInt(nsIRDFInt* aInt)
int32_t value;
aInt->GetValue(&value);
NS_ASSERTION(PL_DHashTableSearch(&mInts, &value),
"int was never registered");
NS_ASSERTION(mInts.Search(&value), "int was never registered");
PL_DHashTableRemove(&mInts, &value);
@ -1478,8 +1474,7 @@ RDFServiceImpl::RegisterDate(nsIRDFDate* aDate)
PRTime value;
aDate->GetValue(&value);
NS_ASSERTION(!PL_DHashTableSearch(&mDates, &value),
"date already registered");
NS_ASSERTION(!mDates.Search(&value), "date already registered");
PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mDates, &value, fallible);
if (! hdr)
@ -1508,8 +1503,7 @@ RDFServiceImpl::UnregisterDate(nsIRDFDate* aDate)
PRTime value;
aDate->GetValue(&value);
NS_ASSERTION(PL_DHashTableSearch(&mDates, &value),
"date was never registered");
NS_ASSERTION(mDates.Search(&value), "date was never registered");
PL_DHashTableRemove(&mDates, &value);
@ -1525,8 +1519,7 @@ RDFServiceImpl::UnregisterDate(nsIRDFDate* aDate)
nsresult
RDFServiceImpl::RegisterBlob(BlobImpl *aBlob)
{
NS_ASSERTION(!PL_DHashTableSearch(&mBlobs, &aBlob->mData),
"blob already registered");
NS_ASSERTION(!mBlobs.Search(&aBlob->mData), "blob already registered");
PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mBlobs, &aBlob->mData, fallible);
if (! hdr)
@ -1550,8 +1543,7 @@ RDFServiceImpl::RegisterBlob(BlobImpl *aBlob)
nsresult
RDFServiceImpl::UnregisterBlob(BlobImpl *aBlob)
{
NS_ASSERTION(PL_DHashTableSearch(&mBlobs, &aBlob->mData),
"blob was never registered");
NS_ASSERTION(mBlobs.Search(&aBlob->mData), "blob was never registered");
PL_DHashTableRemove(&mBlobs, &aBlob->mData);

View File

@ -872,8 +872,7 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
{
{ /* scope for the ReentrantMonitorAutoEnter */
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
PLDHashEntryHdr* entry =
PL_DHashTableSearch(&mTransferringRequests, aRequest);
PLDHashEntryHdr* entry = mTransferringRequests.Search(aRequest);
if (entry) {
mTransferringRequests.RemoveEntry(entry);
requestHasTransferedData = true;

View File

@ -1339,8 +1339,7 @@ void nsDocLoader::RemoveRequestInfo(nsIRequest *aRequest)
nsDocLoader::nsRequestInfo* nsDocLoader::GetRequestInfo(nsIRequest* aRequest)
{
return static_cast<nsRequestInfo*>
(PL_DHashTableSearch(&mRequestInfoHash, aRequest));
return static_cast<nsRequestInfo*>(mRequestInfoHash.Search(aRequest));
}
void nsDocLoader::ClearRequestInfoHash(void)

View File

@ -899,7 +899,7 @@ PtrToNodeEntry*
CCGraph::FindNodeEntry(void* aPtr)
{
return
static_cast<PtrToNodeEntry*>(PL_DHashTableSearch(&mPtrToNodeMap, aPtr));
static_cast<PtrToNodeEntry*>(mPtrToNodeMap.Search(aPtr));
}
PtrInfo*

View File

@ -552,9 +552,7 @@ nsPersistentProperties::GetStringProperty(const nsACString& aKey,
{
const nsAFlatCString& flatKey = PromiseFlatCString(aKey);
PropertyTableEntry* entry = static_cast<PropertyTableEntry*>(
PL_DHashTableSearch(&mTable, flatKey.get()));
auto entry = static_cast<PropertyTableEntry*>(mTable.Search(flatKey.get()));
if (!entry) {
return NS_ERROR_FAILURE;
}
@ -612,7 +610,7 @@ nsPersistentProperties::Undefine(const char* aProp)
NS_IMETHODIMP
nsPersistentProperties::Has(const char* aProp, bool* aResult)
{
*aResult = !!PL_DHashTableSearch(&mTable, aProp);
*aResult = !!mTable.Search(aProp);
return NS_OK;
}

View File

@ -170,8 +170,7 @@ nsStaticCaseInsensitiveNameTable::Lookup(const nsACString& aName)
const nsAFlatCString& str = PromiseFlatCString(aName);
NameTableKey key(&str);
NameTableEntry* entry =
static_cast<NameTableEntry*>(PL_DHashTableSearch(&mNameTable, &key));
auto entry = static_cast<NameTableEntry*>(mNameTable.Search(&key));
return entry ? entry->mIndex : nsStaticCaseInsensitiveNameTable::NOT_FOUND;
}
@ -184,8 +183,7 @@ nsStaticCaseInsensitiveNameTable::Lookup(const nsAString& aName)
const nsAFlatString& str = PromiseFlatString(aName);
NameTableKey key(&str);
NameTableEntry* entry =
static_cast<NameTableEntry*>(PL_DHashTableSearch(&mNameTable, &key));
auto entry = static_cast<NameTableEntry*>(mNameTable.Search(&key));
return entry ? entry->mIndex : nsStaticCaseInsensitiveNameTable::NOT_FOUND;
}

View File

@ -125,8 +125,7 @@ public:
EntryType* GetEntry(KeyType aKey) const
{
return static_cast<EntryType*>(
PL_DHashTableSearch(const_cast<PLDHashTable*>(&mTable),
EntryType::KeyToPointer(aKey)));
const_cast<PLDHashTable*>(&mTable)->Search(EntryType::KeyToPointer(aKey)));
}
/**

View File

@ -554,7 +554,7 @@ PLDHashTable::ComputeKeyHash(const void* aKey)
return keyHash;
}
MOZ_ALWAYS_INLINE PLDHashEntryHdr*
PLDHashEntryHdr*
PLDHashTable::Search(const void* aKey)
{
#ifdef DEBUG
@ -678,12 +678,6 @@ PLDHashTable::RemoveEntry(PLDHashEntryHdr* aEntry)
ShrinkIfAppropriate();
}
PLDHashEntryHdr* PL_DHASH_FASTCALL
PL_DHashTableSearch(PLDHashTable* aTable, const void* aKey)
{
return aTable->Search(aKey);
}
PLDHashEntryHdr* PL_DHASH_FASTCALL
PL_DHashTableAdd(PLDHashTable* aTable, const void* aKey,
const fallible_t& aFallible)

View File

@ -620,12 +620,6 @@ PL_DHashClearEntryStub(PLDHashTable* aTable, PLDHashEntryHdr* aEntry);
const PLDHashTableOps*
PL_DHashGetStubOps(void);
// The following function are deprecated. Use the equivalent class methods
// instead: PLDHashTable::Search() instead of PL_DHashTableSearch(), etc.
PLDHashEntryHdr* PL_DHASH_FASTCALL
PL_DHashTableSearch(PLDHashTable* aTable, const void* aKey);
PLDHashEntryHdr* PL_DHASH_FASTCALL
PL_DHashTableAdd(PLDHashTable* aTable, const void* aKey,
const mozilla::fallible_t&);

View File

@ -128,7 +128,7 @@ TEST(PLDHashTableTest, LazyStorage)
ASSERT_EQ(t.EntryCount(), 0u);
ASSERT_EQ(t.Generation(), 0u);
ASSERT_TRUE(!PL_DHashTableSearch(&t, (const void*)1));
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);