Bug 1124973 (part 2) - Introduce PL_DHashTableSearch(), and replace most PL_DHashTableLookup() calls with it. r=froydnj.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 22 Jan 2015 21:06:55 -0800
changeset 226199 9e2dbe7f144bd4ebcacf6c8ef05912cf9efbcf37
parent 226198 1c86241afc93376e4068c10a07bd0f82d78e5095
child 226200 ec10af0d21816723e3fbae6949dd2f12eb1e3092
push id28187
push usercbook@mozilla.com
push dateWed, 28 Jan 2015 13:20:48 +0000
treeherdermozilla-central@fc21937ca612 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1124973
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1124973 (part 2) - Introduce PL_DHashTableSearch(), and replace most PL_DHashTableLookup() calls with it. r=froydnj. It feels safer to use a function with a new name, rather than just changing the behaviour of the existing function. For most of these cases the PL_DHashTableLookup() result was checked with PL_DHASH_ENTRY_IS_{FREE,BUSY} so the conversion was easy. A few of them preceded that check with a useless null check, but the intent of these was still easy to determine. I'll do the trickier ones in subsequent patches.
dom/base/nsContentUtils.cpp
dom/base/nsDocument.cpp
dom/base/nsPropertyTable.cpp
dom/base/nsScriptNameSpaceManager.cpp
dom/plugins/base/nsJSNPRuntime.cpp
dom/xul/XULDocument.cpp
dom/xul/templates/nsContentSupportMap.h
dom/xul/templates/nsTemplateMap.h
embedding/components/commandhandler/nsCommandParams.cpp
js/xpconnect/src/XPCMaps.h
layout/base/nsFrameManager.cpp
layout/style/nsCSSRuleProcessor.cpp
modules/libpref/prefapi.cpp
netwerk/base/nsLoadGroup.cpp
netwerk/cache/nsCacheEntry.cpp
netwerk/cache/nsDiskCacheBinding.cpp
netwerk/dns/nsHostResolver.cpp
parser/htmlparser/nsHTMLEntities.cpp
rdf/base/nsInMemoryDataSource.cpp
rdf/base/nsRDFService.cpp
security/manager/boot/src/nsSecureBrowserUIImpl.cpp
uriloader/base/nsDocLoader.cpp
xpcom/base/nsCycleCollector.cpp
xpcom/ds/nsPersistentProperties.cpp
xpcom/ds/nsStaticNameTable.cpp
xpcom/glue/nsTHashtable.h
xpcom/glue/pldhash.cpp
xpcom/glue/pldhash.h
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -3936,18 +3936,18 @@ nsContentUtils::TraverseListenerManager(
 {
   if (!sEventListenerManagersHash.IsInitialized()) {
     // We're already shut down, just return.
     return;
   }
 
   EventListenerManagerMapEntry *entry =
     static_cast<EventListenerManagerMapEntry *>
-               (PL_DHashTableLookup(&sEventListenerManagersHash, aNode));
-  if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+               (PL_DHashTableSearch(&sEventListenerManagersHash, aNode));
+  if (entry) {
     CycleCollectionNoteChild(cb, entry->mListenerManager.get(),
                              "[via hash] mListenerManager");
   }
 }
 
 EventListenerManager*
 nsContentUtils::GetListenerManagerForNode(nsINode *aNode)
 {
@@ -3976,43 +3976,43 @@ nsContentUtils::GetListenerManagerForNod
 }
 
 EventListenerManager*
 nsContentUtils::GetExistingListenerManagerForNode(const nsINode *aNode)
 {
   if (!aNode->HasFlag(NODE_HAS_LISTENERMANAGER)) {
     return nullptr;
   }
-  
+
   if (!sEventListenerManagersHash.IsInitialized()) {
     // We're already shut down, don't bother creating an event listener
     // manager.
 
     return nullptr;
   }
 
   EventListenerManagerMapEntry *entry =
     static_cast<EventListenerManagerMapEntry *>
-               (PL_DHashTableLookup(&sEventListenerManagersHash, aNode));
-  if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+               (PL_DHashTableSearch(&sEventListenerManagersHash, aNode));
+  if (entry) {
     return entry->mListenerManager;
   }
 
   return nullptr;
 }
 
 /* static */
 void
 nsContentUtils::RemoveListenerManager(nsINode *aNode)
 {
   if (sEventListenerManagersHash.IsInitialized()) {
     EventListenerManagerMapEntry *entry =
       static_cast<EventListenerManagerMapEntry *>
-                 (PL_DHashTableLookup(&sEventListenerManagersHash, aNode));
-    if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+                 (PL_DHashTableSearch(&sEventListenerManagersHash, aNode));
+    if (entry) {
       nsRefPtr<EventListenerManager> listenerManager;
       listenerManager.swap(entry->mListenerManager);
       // Remove the entry and *then* do operations that could cause further
       // modification of sEventListenerManagersHash.  See bug 334177.
       PL_DHashTableRawRemove(&sEventListenerManagersHash, entry);
       if (listenerManager) {
         listenerManager->Disconnect();
       }
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -3954,19 +3954,19 @@ nsDocument::SetSubDocumentFor(Element* a
   NS_ENSURE_TRUE(aElement, NS_ERROR_UNEXPECTED);
 
   if (!aSubDoc) {
     // aSubDoc is nullptr, remove the mapping
 
     if (mSubDocuments) {
       SubDocMapEntry *entry =
         static_cast<SubDocMapEntry*>
-                   (PL_DHashTableLookup(mSubDocuments, aElement));
-
-      if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+                   (PL_DHashTableSearch(mSubDocuments, aElement));
+
+      if (entry) {
         PL_DHashTableRawRemove(mSubDocuments, entry);
       }
     }
   } else {
     if (!mSubDocuments) {
       // Create a new hashtable
 
       static const PLDHashTableOps hash_table_ops =
@@ -4010,19 +4010,19 @@ nsDocument::SetSubDocumentFor(Element* a
 }
 
 nsIDocument*
 nsDocument::GetSubDocumentFor(nsIContent *aContent) const
 {
   if (mSubDocuments && aContent->IsElement()) {
     SubDocMapEntry *entry =
       static_cast<SubDocMapEntry*>
-                 (PL_DHashTableLookup(mSubDocuments, aContent->AsElement()));
-
-    if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+                 (PL_DHashTableSearch(mSubDocuments, aContent->AsElement()));
+
+    if (entry) {
       return entry->mSubDocument;
     }
   }
 
   return nullptr;
 }
 
 static PLDHashOperator
--- a/dom/base/nsPropertyTable.cpp
+++ b/dom/base/nsPropertyTable.cpp
@@ -89,19 +89,20 @@ nsPropertyTable::DeleteAllPropertiesFor(
 
 nsresult
 nsPropertyTable::TransferOrDeleteAllPropertiesFor(nsPropertyOwner aObject,
                                                   nsPropertyTable *aOtherTable)
 {
   nsresult rv = NS_OK;
   for (PropertyList* prop = mPropertyList; prop; prop = prop->mNext) {
     if (prop->mTransfer) {
-      PropertyListMapEntry *entry = static_cast<PropertyListMapEntry*>
-                                               (PL_DHashTableLookup(&prop->mObjectValueMap, aObject));
-      if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+      PropertyListMapEntry *entry =
+          static_cast<PropertyListMapEntry*>
+                     (PL_DHashTableSearch(&prop->mObjectValueMap, aObject));
+      if (entry) {
         rv = aOtherTable->SetProperty(aObject, prop->mName,
                                       entry->value, prop->mDtorFunc,
                                       prop->mDtorData, prop->mTransfer);
         if (NS_FAILED(rv)) {
           DeleteAllPropertiesFor(aObject);
           aOtherTable->DeleteAllPropertiesFor(aObject);
 
           break;
@@ -120,20 +121,20 @@ nsPropertyTable::TransferOrDeleteAllProp
 
 void
 nsPropertyTable::Enumerate(nsPropertyOwner aObject,
                            NSPropertyFunc aCallback, void *aData)
 {
   PropertyList* prop;
   for (prop = mPropertyList; prop; prop = prop->mNext) {
     PropertyListMapEntry *entry = static_cast<PropertyListMapEntry*>
-      (PL_DHashTableLookup(&prop->mObjectValueMap, aObject));
-    if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+      (PL_DHashTableSearch(&prop->mObjectValueMap, aObject));
+    if (entry) {
       aCallback(const_cast<void*>(aObject.get()), prop->mName, entry->value,
-                 aData);
+                aData);
     }
   }
 }
 
 struct PropertyEnumeratorData
 {
   nsIAtom* mName;
   NSPropertyFunc mCallBack;
@@ -167,19 +168,20 @@ nsPropertyTable::GetPropertyInternal(nsP
                                      nsresult   *aResult)
 {
   NS_PRECONDITION(aPropertyName && aObject, "unexpected null param");
   nsresult rv = NS_PROPTABLE_PROP_NOT_THERE;
   void *propValue = nullptr;
 
   PropertyList* propertyList = GetPropertyListFor(aPropertyName);
   if (propertyList) {
-    PropertyListMapEntry *entry = static_cast<PropertyListMapEntry*>
-                                             (PL_DHashTableLookup(&propertyList->mObjectValueMap, aObject));
-    if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+    PropertyListMapEntry *entry =
+        static_cast<PropertyListMapEntry*>
+                   (PL_DHashTableSearch(&propertyList->mObjectValueMap, aObject));
+    if (entry) {
       propValue = entry->value;
       if (aRemove) {
         // don't call propertyList->mDtorFunc.  That's the caller's job now.
         PL_DHashTableRawRemove(&propertyList->mObjectValueMap, entry);
       }
       rv = NS_OK;
     }
   }
@@ -320,19 +322,20 @@ nsPropertyTable::PropertyList::Destroy()
   // Enumerate any remaining object/value pairs and destroy the value object
   if (mDtorFunc)
     PL_DHashTableEnumerate(&mObjectValueMap, DestroyPropertyEnumerator, this);
 }
 
 bool
 nsPropertyTable::PropertyList::DeletePropertyFor(nsPropertyOwner aObject)
 {
-  PropertyListMapEntry *entry = static_cast<PropertyListMapEntry*>
-                                           (PL_DHashTableLookup(&mObjectValueMap, aObject));
-  if (!PL_DHASH_ENTRY_IS_BUSY(entry))
+  PropertyListMapEntry *entry =
+      static_cast<PropertyListMapEntry*>
+                 (PL_DHashTableSearch(&mObjectValueMap, aObject));
+  if (!entry)
     return false;
 
   void* value = entry->value;
   PL_DHashTableRawRemove(&mObjectValueMap, entry);
 
   if (mDtorFunc)
     mDtorFunc(const_cast<void*>(aObject.get()), mName, value, mDtorData);
 
--- a/dom/base/nsScriptNameSpaceManager.cpp
+++ b/dom/base/nsScriptNameSpaceManager.cpp
@@ -167,20 +167,19 @@ nsScriptNameSpaceManager::RemoveFromHash
 nsGlobalNameStruct*
 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_DHashTableLookup(&mGlobalNames,
+                 (PL_DHashTableSearch(&mGlobalNames,
                                       &aStruct->mAlias->mProtoName));
-
-    if (PL_DHASH_ENTRY_IS_BUSY(proto)) {
+    if (proto) {
       aStruct->mAlias->mProto = &proto->mGlobalName;
     }
   }
   return aStruct->mAlias->mProto;
 }
 
 nsresult
 nsScriptNameSpaceManager::FillHash(nsICategoryManager *aCategoryManager,
@@ -380,19 +379,19 @@ nsScriptNameSpaceManager::Init()
 }
 
 nsGlobalNameStruct*
 nsScriptNameSpaceManager::LookupNameInternal(const nsAString& aName,
                                              const char16_t **aClassName)
 {
   GlobalNameMapEntry *entry =
     static_cast<GlobalNameMapEntry *>
-               (PL_DHashTableLookup(&mGlobalNames, &aName));
+               (PL_DHashTableSearch(&mGlobalNames, &aName));
 
-  if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+  if (entry) {
     if (aClassName) {
       *aClassName = entry->mKey.get();
     }
     return &entry->mGlobalName;
   }
 
   if (aClassName) {
     *aClassName = nullptr;
@@ -400,23 +399,19 @@ nsScriptNameSpaceManager::LookupNameInte
   return nullptr;
 }
 
 const nsGlobalNameStruct*
 nsScriptNameSpaceManager::LookupNavigatorName(const nsAString& aName)
 {
   GlobalNameMapEntry *entry =
     static_cast<GlobalNameMapEntry *>
-               (PL_DHashTableLookup(&mNavigatorNames, &aName));
+               (PL_DHashTableSearch(&mNavigatorNames, &aName));
 
-  if (!PL_DHASH_ENTRY_IS_BUSY(entry)) {
-    return nullptr;
-  }
-
-  return &entry->mGlobalName;
+  return entry ? &entry->mGlobalName : nullptr;
 }
 
 nsresult
 nsScriptNameSpaceManager::RegisterClassName(const char *aClassName,
                                             int32_t aDOMClassInfoID,
                                             bool aPrivileged,
                                             bool aXBLAllowed,
                                             const char16_t **aResult)
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -1767,22 +1767,22 @@ NPObjWrapper_ObjectMoved(JSObject *obj, 
     return;
   }
 
   NPObject *npobj = (NPObject *)::JS_GetPrivate(obj);
   if (!npobj) {
     return;
   }
 
-  // Calling PL_DHashTableLookup() will not result in GC.
+  // Calling PL_DHashTableSearch() will not result in GC.
   JS::AutoSuppressGCAnalysis nogc;
 
   NPObjWrapperHashEntry *entry = static_cast<NPObjWrapperHashEntry *>
-    (PL_DHashTableLookup(&sNPObjWrappers, npobj));
-  MOZ_ASSERT(PL_DHASH_ENTRY_IS_BUSY(entry) && entry->mJSObj);
+    (PL_DHashTableSearch(&sNPObjWrappers, npobj));
+  MOZ_ASSERT(entry && entry->mJSObj);
   MOZ_ASSERT(entry->mJSObj == old);
   entry->mJSObj = obj;
 }
 
 static bool
 NPObjWrapper_Call(JSContext *cx, unsigned argc, JS::Value *vp)
 {
   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
@@ -1824,19 +1824,19 @@ nsNPObjWrapper::OnDestroy(NPObject *npob
 
   if (!sNPObjWrappers.IsInitialized()) {
     // No hash yet (or any more), no used wrappers available.
 
     return;
   }
 
   NPObjWrapperHashEntry *entry = static_cast<NPObjWrapperHashEntry *>
-    (PL_DHashTableLookup(&sNPObjWrappers, npobj));
-
-  if (PL_DHASH_ENTRY_IS_BUSY(entry) && entry->mJSObj) {
+    (PL_DHashTableSearch(&sNPObjWrappers, npobj));
+
+  if (entry && entry->mJSObj) {
     // Found a live NPObject wrapper, null out its JSObjects' private
     // data.
 
     ::JS_SetPrivate(entry->mJSObj, nullptr);
 
     // Remove the npobj from the hash now that it went away.
     PL_DHashTableRawRemove(&sNPObjWrappers, entry);
 
@@ -1908,19 +1908,17 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JS
 
   JS::Rooted<JSObject*> obj(cx, ::JS_NewObject(cx, js::Jsvalify(&sNPObjectJSWrapperClass),
                                                JS::NullPtr(), JS::NullPtr()));
 
   if (generation != sNPObjWrappers.Generation()) {
       // Reload entry if the JS_NewObject call caused a GC and reallocated
       // the table (see bug 445229). This is guaranteed to succeed.
 
-      entry = static_cast<NPObjWrapperHashEntry *>
-        (PL_DHashTableLookup(&sNPObjWrappers, npobj));
-      NS_ASSERTION(entry && PL_DHASH_ENTRY_IS_BUSY(entry),
+      NS_ASSERTION(PL_DHashTableSearch(&sNPObjWrappers, npobj),
                    "Hashtable didn't find what we just added?");
   }
 
   if (!obj) {
     // OOM? Remove the stale entry from the hash.
 
     PL_DHashTableRawRemove(&sNPObjWrappers, entry);
 
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -773,19 +773,19 @@ XULDocument::AddBroadcastListenerFor(Ele
         if (! mBroadcasterMap) {
             aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
             return;
         }
     }
 
     BroadcasterMapEntry* entry =
         static_cast<BroadcasterMapEntry*>
-                   (PL_DHashTableLookup(mBroadcasterMap, &aBroadcaster));
-
-    if (PL_DHASH_ENTRY_IS_FREE(entry)) {
+                   (PL_DHashTableSearch(mBroadcasterMap, &aBroadcaster));
+
+    if (!entry) {
         entry =
             static_cast<BroadcasterMapEntry*>
                        (PL_DHashTableAdd(mBroadcasterMap, &aBroadcaster));
 
         if (! entry) {
             aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
             return;
         }
@@ -839,19 +839,19 @@ XULDocument::RemoveBroadcastListenerFor(
 {
     // If we haven't added any broadcast listeners, then there sure
     // aren't any to remove.
     if (! mBroadcasterMap)
         return;
 
     BroadcasterMapEntry* entry =
         static_cast<BroadcasterMapEntry*>
-                   (PL_DHashTableLookup(mBroadcasterMap, &aBroadcaster));
-
-    if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+                   (PL_DHashTableSearch(mBroadcasterMap, &aBroadcaster));
+
+    if (entry) {
         nsCOMPtr<nsIAtom> attr = do_GetAtom(aAttr);
         for (int32_t i = entry->mListeners.Count() - 1; i >= 0; --i) {
             BroadcastListener* bl =
                 static_cast<BroadcastListener*>(entry->mListeners[i]);
 
             nsCOMPtr<Element> blListener = do_QueryReferent(bl->mListener);
 
             if (blListener == &aListener && bl->mAttribute == attr) {
@@ -953,27 +953,27 @@ XULDocument::AttributeChanged(nsIDocumen
     // Might not need this, but be safe for now.
     nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
 
     // XXXbz check aNameSpaceID, dammit!
     // See if we need to update our ref map.
     if (aAttribute == nsGkAtoms::ref) {
         AddElementToRefMap(aElement);
     }
-    
+
     nsresult rv;
 
     // Synchronize broadcast listeners
     if (mBroadcasterMap &&
         CanBroadcast(aNameSpaceID, aAttribute)) {
         BroadcasterMapEntry* entry =
             static_cast<BroadcasterMapEntry*>
-                       (PL_DHashTableLookup(mBroadcasterMap, aElement));
-
-        if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+                       (PL_DHashTableSearch(mBroadcasterMap, aElement));
+
+        if (entry) {
             // We've got listeners: push the value.
             nsAutoString value;
             bool attrSet = aElement->GetAttr(kNameSpaceID_None, aAttribute, value);
 
             int32_t i;
             for (i = entry->mListeners.Count() - 1; i >= 0; --i) {
                 BroadcastListener* bl =
                     static_cast<BroadcastListener*>(entry->mListeners[i]);
@@ -4155,18 +4155,18 @@ XULDocument::BroadcastAttributeChangeFro
 
     if (!mBroadcasterMap || !CanBroadcast(aNameSpaceID, aAttribute))
         return rv;
 
     if (!aNode->IsElement())
         return rv;
 
     BroadcasterMapEntry* entry = static_cast<BroadcasterMapEntry*>
-        (PL_DHashTableLookup(mBroadcasterMap, aNode->AsElement()));
-    if (!PL_DHASH_ENTRY_IS_BUSY(entry))
+        (PL_DHashTableSearch(mBroadcasterMap, aNode->AsElement()));
+    if (!entry)
         return rv;
 
     // We've got listeners: push the value.
     int32_t i;
     for (i = entry->mListeners.Count() - 1; i >= 0; --i) {
         BroadcastListener* bl = static_cast<BroadcastListener*>
             (entry->mListeners[i]);
 
--- a/dom/xul/templates/nsContentSupportMap.h
+++ b/dom/xul/templates/nsContentSupportMap.h
@@ -38,18 +38,18 @@ public:
         entry->mMatch   = aMatch;
         return NS_OK;
     }
 
     bool Get(nsIContent* aElement, nsTemplateMatch** aMatch) {
         if (!mMap.IsInitialized())
             return false;
 
-        PLDHashEntryHdr* hdr = PL_DHashTableLookup(&mMap, aElement);
-        if (PL_DHASH_ENTRY_IS_FREE(hdr))
+        PLDHashEntryHdr* hdr = PL_DHashTableSearch(&mMap, aElement);
+        if (!hdr)
             return false;
 
         Entry* entry = static_cast<Entry*>(hdr);
         *aMatch = entry->mMatch;
         return true;
     }
 
     nsresult Remove(nsIContent* aElement);
--- a/dom/xul/templates/nsTemplateMap.h
+++ b/dom/xul/templates/nsTemplateMap.h
@@ -29,17 +29,17 @@ protected:
 
 public:
     nsTemplateMap() { Init(); }
 
     ~nsTemplateMap() { Finish(); }
 
     void
     Put(nsIContent* aContent, nsIContent* aTemplate) {
-        NS_ASSERTION(PL_DHASH_ENTRY_IS_FREE(PL_DHashTableLookup(&mTable, aContent)),
+        NS_ASSERTION(!PL_DHashTableSearch(&mTable, aContent),
                      "aContent already in map");
 
         Entry* entry = static_cast<Entry*>(PL_DHashTableAdd(&mTable, aContent));
 
         if (entry) {
             entry->mContent = aContent;
             entry->mTemplate = aTemplate;
         }
@@ -55,19 +55,19 @@ public:
             Remove(child);
         }
     }
 
 
     void
     GetTemplateFor(nsIContent* aContent, nsIContent** aResult) {
         Entry* entry =
-            static_cast<Entry*>(PL_DHashTableLookup(&mTable, aContent));
+            static_cast<Entry*>(PL_DHashTableSearch(&mTable, aContent));
 
-        if (PL_DHASH_ENTRY_IS_BUSY(entry))
+        if (entry)
             NS_IF_ADDREF(*aResult = entry->mTemplate);
         else
             *aResult = nullptr;
     }
 
     void
     Clear() { Finish(); Init(); }
 };
--- a/embedding/components/commandhandler/nsCommandParams.cpp
+++ b/embedding/components/commandhandler/nsCommandParams.cpp
@@ -212,30 +212,25 @@ nsCommandParams::RemoveValue(const char*
   // return NS_OK unconditionally.
   (void)PL_DHashTableRemove(&mValuesHash, (void *)aName);
   return NS_OK;
 }
 
 nsCommandParams::HashEntry*
 nsCommandParams::GetNamedEntry(const char* aName)
 {
-  HashEntry *foundEntry =
-    (HashEntry *)PL_DHashTableLookup(&mValuesHash, (void *)aName);
-  if (PL_DHASH_ENTRY_IS_BUSY(foundEntry)) {
-    return foundEntry;
-  }
-  return nullptr;
+  return (HashEntry *)PL_DHashTableSearch(&mValuesHash, (void *)aName);
 }
 
 nsCommandParams::HashEntry*
 nsCommandParams::GetOrMakeEntry(const char* aName, uint8_t entryType)
 {
   HashEntry *foundEntry =
-    (HashEntry *)PL_DHashTableLookup(&mValuesHash, (void *)aName);
-  if (PL_DHASH_ENTRY_IS_BUSY(foundEntry)) { // reuse existing entry
+    (HashEntry *)PL_DHashTableSearch(&mValuesHash, (void *)aName);
+  if (foundEntry) { // reuse existing entry
     foundEntry->Reset(entryType);
     return foundEntry;
   }
 
   foundEntry = (HashEntry *)PL_DHashTableAdd(&mValuesHash, (void *)aName);
   if (!foundEntry) {
     return nullptr;
   }
--- a/js/xpconnect/src/XPCMaps.h
+++ b/js/xpconnect/src/XPCMaps.h
@@ -106,20 +106,18 @@ public:
         XPCWrappedNative* value;
     };
 
     static Native2WrappedNativeMap* newMap(int length);
 
     inline XPCWrappedNative* Find(nsISupports* Obj)
     {
         NS_PRECONDITION(Obj,"bad param");
-        Entry* entry = (Entry*) PL_DHashTableLookup(mTable, Obj);
-        if (PL_DHASH_ENTRY_IS_FREE(entry))
-            return nullptr;
-        return entry->value;
+        Entry* entry = (Entry*) PL_DHashTableSearch(mTable, Obj);
+        return entry ? entry->value : nullptr;
     }
 
     inline XPCWrappedNative* Add(XPCWrappedNative* wrapper)
     {
         NS_PRECONDITION(wrapper,"bad param");
         nsISupports* obj = wrapper->GetIdentityObject();
         MOZ_ASSERT(!Find(obj), "wrapper already in new scope!");
         Entry* entry = (Entry*) PL_DHashTableAdd(mTable, obj);
@@ -174,20 +172,18 @@ public:
 
         static const struct PLDHashTableOps sOps;
     };
 
     static IID2WrappedJSClassMap* newMap(int length);
 
     inline nsXPCWrappedJSClass* Find(REFNSIID iid)
     {
-        Entry* entry = (Entry*) PL_DHashTableLookup(mTable, &iid);
-        if (PL_DHASH_ENTRY_IS_FREE(entry))
-            return nullptr;
-        return entry->value;
+        Entry* entry = (Entry*) PL_DHashTableSearch(mTable, &iid);
+        return entry ? entry->value : nullptr;
     }
 
     inline nsXPCWrappedJSClass* Add(nsXPCWrappedJSClass* clazz)
     {
         NS_PRECONDITION(clazz,"bad param");
         const nsIID* iid = &clazz->GetIID();
         Entry* entry = (Entry*) PL_DHashTableAdd(mTable, iid);
         if (!entry)
@@ -229,20 +225,18 @@ public:
 
         static const struct PLDHashTableOps sOps;
     };
 
     static IID2NativeInterfaceMap* newMap(int length);
 
     inline XPCNativeInterface* Find(REFNSIID iid)
     {
-        Entry* entry = (Entry*) PL_DHashTableLookup(mTable, &iid);
-        if (PL_DHASH_ENTRY_IS_FREE(entry))
-            return nullptr;
-        return entry->value;
+        Entry* entry = (Entry*) PL_DHashTableSearch(mTable, &iid);
+        return entry ? entry->value : nullptr;
     }
 
     inline XPCNativeInterface* Add(XPCNativeInterface* iface)
     {
         NS_PRECONDITION(iface,"bad param");
         const nsIID* iid = iface->GetIID();
         Entry* entry = (Entry*) PL_DHashTableAdd(mTable, iid);
         if (!entry)
@@ -287,20 +281,18 @@ public:
         nsIClassInfo* key;
         XPCNativeSet* value;
     };
 
     static ClassInfo2NativeSetMap* newMap(int length);
 
     inline XPCNativeSet* Find(nsIClassInfo* info)
     {
-        Entry* entry = (Entry*) PL_DHashTableLookup(mTable, info);
-        if (PL_DHASH_ENTRY_IS_FREE(entry))
-            return nullptr;
-        return entry->value;
+        Entry* entry = (Entry*) PL_DHashTableSearch(mTable, info);
+        return entry ? entry->value : nullptr;
     }
 
     inline XPCNativeSet* Add(nsIClassInfo* info, XPCNativeSet* set)
     {
         NS_PRECONDITION(info,"bad param");
         Entry* entry = (Entry*) PL_DHashTableAdd(mTable, info);
         if (!entry)
             return nullptr;
@@ -345,20 +337,18 @@ public:
         nsIClassInfo*          key;
         XPCWrappedNativeProto* value;
     };
 
     static ClassInfo2WrappedNativeProtoMap* newMap(int length);
 
     inline XPCWrappedNativeProto* Find(nsIClassInfo* info)
     {
-        Entry* entry = (Entry*) PL_DHashTableLookup(mTable, info);
-        if (PL_DHASH_ENTRY_IS_FREE(entry))
-            return nullptr;
-        return entry->value;
+        Entry* entry = (Entry*) PL_DHashTableSearch(mTable, info);
+        return entry ? entry->value : nullptr;
     }
 
     inline XPCWrappedNativeProto* Add(nsIClassInfo* info, XPCWrappedNativeProto* proto)
     {
         NS_PRECONDITION(info,"bad param");
         Entry* entry = (Entry*) PL_DHashTableAdd(mTable, info);
         if (!entry)
             return nullptr;
@@ -408,20 +398,18 @@ public:
 
         static const struct PLDHashTableOps sOps;
     };
 
     static NativeSetMap* newMap(int length);
 
     inline XPCNativeSet* Find(XPCNativeSetKey* key)
     {
-        Entry* entry = (Entry*) PL_DHashTableLookup(mTable, key);
-        if (PL_DHASH_ENTRY_IS_FREE(entry))
-            return nullptr;
-        return entry->key_value;
+        Entry* entry = (Entry*) PL_DHashTableSearch(mTable, key);
+        return entry ? entry->key_value : nullptr;
     }
 
     inline XPCNativeSet* Add(const XPCNativeSetKey* key, XPCNativeSet* set)
     {
         NS_PRECONDITION(key,"bad param");
         NS_PRECONDITION(set,"bad param");
         Entry* entry = (Entry*) PL_DHashTableAdd(mTable, key);
         if (!entry)
@@ -483,20 +471,18 @@ public:
 
         static const struct PLDHashTableOps sOps;
     };
 
     static IID2ThisTranslatorMap* newMap(int length);
 
     inline nsIXPCFunctionThisTranslator* Find(REFNSIID iid)
     {
-        Entry* entry = (Entry*) PL_DHashTableLookup(mTable, &iid);
-        if (PL_DHASH_ENTRY_IS_FREE(entry))
-            return nullptr;
-        return entry->value;
+        Entry* entry = (Entry*) PL_DHashTableSearch(mTable, &iid);
+        return entry ? entry->value : nullptr;
     }
 
     inline nsIXPCFunctionThisTranslator* Add(REFNSIID iid,
                                              nsIXPCFunctionThisTranslator* obj)
     {
 
         Entry* entry = (Entry*) PL_DHashTableAdd(mTable, &iid);
         if (!entry)
--- a/layout/base/nsFrameManager.cpp
+++ b/layout/base/nsFrameManager.cpp
@@ -150,19 +150,19 @@ nsFrameManager::Destroy()
 // Placeholder frame functions
 nsPlaceholderFrame*
 nsFrameManager::GetPlaceholderFrameFor(const nsIFrame* aFrame)
 {
   NS_PRECONDITION(aFrame, "null param unexpected");
 
   if (mPlaceholderMap.IsInitialized()) {
     PlaceholderMapEntry *entry = static_cast<PlaceholderMapEntry*>
-                                            (PL_DHashTableLookup(const_cast<PLDHashTable*>(&mPlaceholderMap),
+                                            (PL_DHashTableSearch(const_cast<PLDHashTable*>(&mPlaceholderMap),
                                 aFrame));
-    if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+    if (entry) {
       return entry->placeholderFrame;
     }
   }
 
   return nullptr;
 }
 
 nsresult
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -695,43 +695,43 @@ void RuleHash::EnumerateAllRules(Element
 
   if (mUniversalRules.Length() != 0) { // universal rules
     mEnumList[valueCount++] = ToEnumData(mUniversalRules);
     RULE_HASH_STAT_INCREMENT_LIST_COUNT(mUniversalRules, mElementUniversalCalls);
   }
   // universal rules within the namespace
   if (kNameSpaceID_Unknown != nameSpace && mNameSpaceTable.IsInitialized()) {
     RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
-                                           (PL_DHashTableLookup(&mNameSpaceTable, NS_INT32_TO_PTR(nameSpace)));
-    if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+                                           (PL_DHashTableSearch(&mNameSpaceTable, NS_INT32_TO_PTR(nameSpace)));
+    if (entry) {
       mEnumList[valueCount++] = ToEnumData(entry->mRules);
       RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementNameSpaceCalls);
     }
   }
   if (mTagTable.IsInitialized()) {
     RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
-                                           (PL_DHashTableLookup(&mTagTable, tag));
-    if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+                                           (PL_DHashTableSearch(&mTagTable, tag));
+    if (entry) {
       mEnumList[valueCount++] = ToEnumData(entry->mRules);
       RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementTagCalls);
     }
   }
   if (id && mIdTable.IsInitialized()) {
     RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
-                                           (PL_DHashTableLookup(&mIdTable, id));
-    if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+                                           (PL_DHashTableSearch(&mIdTable, id));
+    if (entry) {
       mEnumList[valueCount++] = ToEnumData(entry->mRules);
       RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementIdCalls);
     }
   }
   if (mClassTable.IsInitialized()) {
     for (int32_t index = 0; index < classCount; ++index) {
       RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
-                                             (PL_DHashTableLookup(&mClassTable, classList->AtomAt(index)));
-      if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+                                             (PL_DHashTableSearch(&mClassTable, classList->AtomAt(index)));
+      if (entry) {
         mEnumList[valueCount++] = ToEnumData(entry->mRules);
         RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementClassCalls);
       }
     }
   }
   NS_ASSERTION(valueCount <= testCount, "values exceeded list size");
 
   if (valueCount > 0) {
@@ -2577,18 +2577,18 @@ nsCSSRuleProcessor::RulesMatching(Pseudo
 
 /* virtual */ void
 nsCSSRuleProcessor::RulesMatching(AnonBoxRuleProcessorData* aData)
 {
   RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
 
   if (cascade && cascade->mAnonBoxRules.EntryCount()) {
     RuleHashTagTableEntry* entry = static_cast<RuleHashTagTableEntry*>
-      (PL_DHashTableLookup(&cascade->mAnonBoxRules, aData->mPseudoTag));
-    if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+      (PL_DHashTableSearch(&cascade->mAnonBoxRules, aData->mPseudoTag));
+    if (entry) {
       nsTArray<RuleValue>& rules = entry->mRules;
       for (RuleValue *value = rules.Elements(), *end = value + rules.Length();
            value != end; ++value) {
         value->mRule->RuleMatched();
         aData->mRuleWalker->Forward(value->mRule);
       }
     }
   }
@@ -2597,18 +2597,18 @@ nsCSSRuleProcessor::RulesMatching(AnonBo
 #ifdef MOZ_XUL
 /* virtual */ void
 nsCSSRuleProcessor::RulesMatching(XULTreeRuleProcessorData* aData)
 {
   RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
 
   if (cascade && cascade->mXULTreeRules.EntryCount()) {
     RuleHashTagTableEntry* entry = static_cast<RuleHashTagTableEntry*>
-      (PL_DHashTableLookup(&cascade->mXULTreeRules, aData->mPseudoTag));
-    if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+      (PL_DHashTableSearch(&cascade->mXULTreeRules, aData->mPseudoTag));
+    if (entry) {
       NodeMatchContext nodeContext(EventStates(),
                                    nsCSSRuleProcessor::IsLink(aData->mElement));
       nsTArray<RuleValue>& rules = entry->mRules;
       for (RuleValue *value = rules.Elements(), *end = value + rules.Length();
            value != end; ++value) {
         if (aData->mComparator->PseudoMatches(value->mSelector)) {
           ContentEnumFunc(*value, value->mSelector->mNext, aData, nodeContext,
                           nullptr);
@@ -2832,49 +2832,49 @@ nsCSSRuleProcessor::HasAttributeDependen
   // rules we might stop matching; if the after change notification, the
   // ones we might have started matching.
   if (cascade) {
     if (aData->mAttribute == nsGkAtoms::id) {
       nsIAtom* id = aData->mElement->GetID();
       if (id) {
         AtomSelectorEntry *entry =
           static_cast<AtomSelectorEntry*>
-                     (PL_DHashTableLookup(&cascade->mIdSelectors, id));
-        if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+                     (PL_DHashTableSearch(&cascade->mIdSelectors, id));
+        if (entry) {
           EnumerateSelectors(entry->mSelectors, &data);
         }
       }
 
       EnumerateSelectors(cascade->mPossiblyNegatedIDSelectors, &data);
     }
-    
+
     if (aData->mAttribute == nsGkAtoms::_class) {
       const nsAttrValue* elementClasses = aData->mElement->GetClasses();
       if (elementClasses) {
         int32_t atomCount = elementClasses->GetAtomCount();
         for (int32_t i = 0; i < atomCount; ++i) {
           nsIAtom* curClass = elementClasses->AtomAt(i);
           AtomSelectorEntry *entry =
             static_cast<AtomSelectorEntry*>
-                       (PL_DHashTableLookup(&cascade->mClassSelectors,
+                       (PL_DHashTableSearch(&cascade->mClassSelectors,
                                             curClass));
-          if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+          if (entry) {
             EnumerateSelectors(entry->mSelectors, &data);
           }
         }
       }
 
       EnumerateSelectors(cascade->mPossiblyNegatedClassSelectors, &data);
     }
 
     AtomSelectorEntry *entry =
       static_cast<AtomSelectorEntry*>
-                 (PL_DHashTableLookup(&cascade->mAttributeSelectors,
+                 (PL_DHashTableSearch(&cascade->mAttributeSelectors,
                                       aData->mAttribute));
-    if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
+    if (entry) {
       EnumerateSelectors(entry->mSelectors, &data);
     }
   }
 
   return data.change;
 }
 
 /* virtual */ bool
--- a/modules/libpref/prefapi.cpp
+++ b/modules/libpref/prefapi.cpp
@@ -723,23 +723,17 @@ static void pref_SetValue(PrefValue* exi
 }
 
 PrefHashEntry* pref_HashTableLookup(const void *key)
 {
 #ifndef MOZ_B2G
     MOZ_ASSERT(NS_IsMainThread());
 #endif
 
-    PrefHashEntry* result =
-        static_cast<PrefHashEntry*>(PL_DHashTableLookup(&gHashTable, key));
-
-    if (PL_DHASH_ENTRY_IS_FREE(result))
-        return nullptr;
-
-    return result;
+    return static_cast<PrefHashEntry*>(PL_DHashTableSearch(&gHashTable, key));
 }
 
 nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, uint32_t flags)
 {
 #ifndef MOZ_B2G
     MOZ_ASSERT(NS_IsMainThread());
 #endif
 
--- a/netwerk/base/nsLoadGroup.cpp
+++ b/netwerk/base/nsLoadGroup.cpp
@@ -252,25 +252,19 @@ nsLoadGroup::Cancel(nsresult status)
 
     nsresult firstError = NS_OK;
 
     while (count > 0) {
         nsIRequest* request = requests.ElementAt(--count);
 
         NS_ASSERTION(request, "NULL request found in list.");
 
-        RequestMapEntry *entry =
-            static_cast<RequestMapEntry *>
-                       (PL_DHashTableLookup(&mRequests, request));
-
-        if (PL_DHASH_ENTRY_IS_FREE(entry)) {
+        if (!PL_DHashTableSearch(&mRequests, request)) {
             // |request| was removed already
-
             NS_RELEASE(request);
-
             continue;
         }
 
 #if defined(PR_LOGGING)
         nsAutoCString nameStr;
         request->GetName(nameStr);
         LOG(("LOADGROUP [%x]: Canceling request %x %s.\n",
              this, request, nameStr.get()));
@@ -482,26 +476,18 @@ nsLoadGroup::AddRequest(nsIRequest *requ
     {
         nsAutoCString nameStr;
         request->GetName(nameStr);
         LOG(("LOADGROUP [%x]: Adding request %x %s (count=%d).\n",
              this, request, nameStr.get(), mRequests.EntryCount()));
     }
 #endif /* PR_LOGGING */
 
-#ifdef DEBUG
-    {
-      RequestMapEntry *entry =
-          static_cast<RequestMapEntry *>
-                     (PL_DHashTableLookup(&mRequests, request));
-
-      NS_ASSERTION(PL_DHASH_ENTRY_IS_FREE(entry),
-                   "Entry added to loadgroup twice, don't do that");
-    }
-#endif
+    NS_ASSERTION(!PL_DHashTableSearch(&mRequests, request),
+                 "Entry added to loadgroup twice, don't do that");
 
     //
     // Do not add the channel, if the loadgroup is being canceled...
     //
     if (mIsCanceling) {
 
 #if defined(PR_LOGGING)
         LOG(("LOADGROUP [%x]: AddChannel() ABORTED because LoadGroup is"
@@ -605,19 +591,19 @@ nsLoadGroup::RemoveRequest(nsIRequest *r
 
     //
     // Remove the request from the group.  If this fails, it means that
     // 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_DHashTableLookup(&mRequests, request));
+                   (PL_DHashTableSearch(&mRequests, request));
 
-    if (PL_DHASH_ENTRY_IS_FREE(entry)) {
+    if (!entry) {
         LOG(("LOADGROUP [%x]: Unable to remove request %x. Not in group!\n",
             this, request));
 
         return NS_ERROR_FAILURE;
     }
 
     PL_DHashTableRawRemove(&mRequests, entry);
 
--- a/netwerk/cache/nsCacheEntry.cpp
+++ b/netwerk/cache/nsCacheEntry.cpp
@@ -420,27 +420,22 @@ nsCacheEntryHashTable::Shutdown()
         initialized = false;
     }
 }
 
 
 nsCacheEntry *
 nsCacheEntryHashTable::GetEntry( const nsCString * key)
 {
-    PLDHashEntryHdr *hashEntry;
-    nsCacheEntry    *result = nullptr;
-
     NS_ASSERTION(initialized, "nsCacheEntryHashTable not initialized");
     if (!initialized)  return nullptr;
-    
-    hashEntry = PL_DHashTableLookup(&table, key);
-    if (PL_DHASH_ENTRY_IS_BUSY(hashEntry)) {
-        result = ((nsCacheEntryHashTableEntry *)hashEntry)->cacheEntry;
-    }
-    return result;
+
+    PLDHashEntryHdr *hashEntry = PL_DHashTableSearch(&table, key);
+    return hashEntry ? ((nsCacheEntryHashTableEntry *)hashEntry)->cacheEntry
+                     : nullptr;
 }
 
 
 nsresult
 nsCacheEntryHashTable::AddEntry( nsCacheEntry *cacheEntry)
 {
     PLDHashEntryHdr    *hashEntry;
 
--- a/netwerk/cache/nsDiskCacheBinding.cpp
+++ b/netwerk/cache/nsDiskCacheBinding.cpp
@@ -196,23 +196,23 @@ nsDiskCacheBindery::CreateBinding(nsCach
  */
 nsDiskCacheBinding *
 nsDiskCacheBindery::FindActiveBinding(uint32_t  hashNumber)
 {
     NS_ASSERTION(initialized, "nsDiskCacheBindery not initialized");
     // find hash entry for key
     HashTableEntry * hashEntry;
     hashEntry =
-      (HashTableEntry *) PL_DHashTableLookup(&table,
+      (HashTableEntry *) PL_DHashTableSearch(&table,
                                              (void*)(uintptr_t) hashNumber);
-    if (PL_DHASH_ENTRY_IS_FREE(hashEntry)) return nullptr;
+    if (!hashEntry) return nullptr;
 
     // walk list looking for active entry
     NS_ASSERTION(hashEntry->mBinding, "hash entry left with no binding");
-    nsDiskCacheBinding * binding = hashEntry->mBinding;    
+    nsDiskCacheBinding * binding = hashEntry->mBinding;
     while (binding->mCacheEntry->IsDoomed()) {
         binding = (nsDiskCacheBinding *)PR_NEXT_LINK(binding);
         if (binding == hashEntry->mBinding)  return nullptr;
     }
     return binding;
 }
 
 
@@ -293,19 +293,19 @@ void
 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_DHashTableLookup(&table,
+    hashEntry = (HashTableEntry*) PL_DHashTableSearch(&table,
                                                       (void*)(uintptr_t) key);
-    if (!PL_DHASH_ENTRY_IS_BUSY(hashEntry)) {
+    if (!hashEntry) {
         NS_WARNING("### disk cache: binding not in hashtable!");
         return;
     }
     
     if (binding == hashEntry->mBinding) {
         if (PR_CLIST_IS_EMPTY(binding)) {
             // remove this hash entry
             PL_DHashTableRemove(&table,
--- a/netwerk/dns/nsHostResolver.cpp
+++ b/netwerk/dns/nsHostResolver.cpp
@@ -824,22 +824,21 @@ nsHostResolver::ResolveHost(const char  
             // If this is an IPV4 or IPV6 specific request, check if there is
             // an AF_UNSPEC entry we can use. Otherwise, hit the resolver...
             else if (!he->rec->resolving) {
                 if (!(flags & RES_BYPASS_CACHE) &&
                     ((af == PR_AF_INET) || (af == PR_AF_INET6))) {
                     // First, search for an entry with AF_UNSPEC
                     const nsHostKey unspecKey = { host, flags, PR_AF_UNSPEC };
                     nsHostDBEnt *unspecHe = static_cast<nsHostDBEnt *>
-                        (PL_DHashTableLookup(&mDB, &unspecKey));
-                    NS_ASSERTION(PL_DHASH_ENTRY_IS_FREE(unspecHe) ||
-                                 (PL_DHASH_ENTRY_IS_BUSY(unspecHe) &&
-                                  unspecHe->rec),
+                        (PL_DHashTableSearch(&mDB, &unspecKey));
+                    NS_ASSERTION(!unspecHe ||
+                                 (unspecHe && unspecHe->rec),
                                 "Valid host entries should contain a record");
-                    if (PL_DHASH_ENTRY_IS_BUSY(unspecHe) &&
+                    if (unspecHe &&
                         unspecHe->rec &&
                         unspecHe->rec->HasUsableResult(TimeStamp::NowLoRes(), flags)) {
 
                         MOZ_ASSERT(unspecHe->rec->addr_info || unspecHe->rec->negative,
                                    "Entry should be resolved or negative.");
 
                         LOG(("  Trying AF_UNSPEC entry for [%s] af: %s.\n",
                             host, (af == PR_AF_INET) ? "AF_INET" : "AF_INET6"));
--- a/parser/htmlparser/nsHTMLEntities.cpp
+++ b/parser/htmlparser/nsHTMLEntities.cpp
@@ -150,25 +150,22 @@ nsHTMLEntities::EntityToUnicode(const ns
     //this little piece of code exists because entities may or may not have the terminating ';'.
     //if we see it, strip if off for this test...
 
     if(';'==aEntity.Last()) {
       nsAutoCString temp(aEntity);
       temp.Truncate(aEntity.Length()-1);
       return EntityToUnicode(temp);
     }
-      
-  EntityNodeEntry* entry = 
-    static_cast<EntityNodeEntry*>
-               (PL_DHashTableLookup(&gEntityToUnicode, aEntity.get()));
 
-  if (!entry || PL_DHASH_ENTRY_IS_FREE(entry))
-  return -1;
-        
-  return entry->node->mUnicode;
+  EntityNodeEntry* entry =
+    static_cast<EntityNodeEntry*>
+               (PL_DHashTableSearch(&gEntityToUnicode, aEntity.get()));
+
+  return entry ? entry->node->mUnicode : -1;
 }
 
 
 int32_t 
 nsHTMLEntities::EntityToUnicode(const nsAString& aEntity) {
   nsAutoCString theEntity; theEntity.AssignWithConversion(aEntity);
   if(';'==theEntity.Last()) {
     theEntity.Truncate(theEntity.Length()-1);
@@ -180,22 +177,19 @@ nsHTMLEntities::EntityToUnicode(const ns
 
 const char*
 nsHTMLEntities::UnicodeToEntity(int32_t aUnicode)
 {
   NS_ASSERTION(gUnicodeToEntity.IsInitialized(),
                "no lookup table, needs addref");
   EntityNodeEntry* entry =
     static_cast<EntityNodeEntry*>
-               (PL_DHashTableLookup(&gUnicodeToEntity, NS_INT32_TO_PTR(aUnicode)));
-                   
-  if (!entry || PL_DHASH_ENTRY_IS_FREE(entry))
-  return nullptr;
-    
-  return entry->node->mStr;
+               (PL_DHashTableSearch(&gUnicodeToEntity, NS_INT32_TO_PTR(aUnicode)));
+
+  return entry ? entry->node->mStr : nullptr;
 }
 
 #ifdef DEBUG
 #include <stdio.h>
 
 class nsTestEntityTable {
 public:
    nsTestEntityTable() {
--- a/rdf/base/nsInMemoryDataSource.cpp
+++ b/rdf/base/nsInMemoryDataSource.cpp
@@ -314,28 +314,24 @@ protected:
     static PLDHashOperator
     SweepForwardArcsEntries(PLDHashTable* aTable, PLDHashEntryHdr* aHdr,
                             uint32_t aNumber, void* aArg);
 
 public:
     // Implementation methods
     Assertion*
     GetForwardArcs(nsIRDFResource* u) {
-        PLDHashEntryHdr* hdr = PL_DHashTableLookup(&mForwardArcs, u);
-        return PL_DHASH_ENTRY_IS_BUSY(hdr)
-            ? static_cast<Entry*>(hdr)->mAssertions
-            : nullptr;
+        PLDHashEntryHdr* hdr = PL_DHashTableSearch(&mForwardArcs, u);
+        return hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
     }
 
     Assertion*
     GetReverseArcs(nsIRDFNode* v) {
-        PLDHashEntryHdr* hdr = PL_DHashTableLookup(&mReverseArcs, v);
-        return PL_DHASH_ENTRY_IS_BUSY(hdr)
-            ? static_cast<Entry*>(hdr)->mAssertions
-            : nullptr;
+        PLDHashEntryHdr* hdr = PL_DHashTableSearch(&mReverseArcs, v);
+        return hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
     }
 
     void
     SetForwardArcs(nsIRDFResource* u, Assertion* as) {
         if (as) {
             Entry* entry = static_cast<Entry*>(PL_DHashTableAdd(&mForwardArcs, u));
             if (entry) {
                 entry->mNode = u;
@@ -440,21 +436,21 @@ InMemoryAssertionEnumeratorImpl::InMemor
     NS_ADDREF(mProperty);
     NS_IF_ADDREF(mTarget);
 
     if (mSource) {
         mNextAssertion = mDataSource->GetForwardArcs(mSource);
 
         if (mNextAssertion && mNextAssertion->mHashEntry) {
             // its our magical HASH_ENTRY forward hash for assertions
-            PLDHashEntryHdr* hdr = PL_DHashTableLookup(mNextAssertion->u.hash.mPropertyHash,
-                aProperty);
-            mNextAssertion = PL_DHASH_ENTRY_IS_BUSY(hdr)
-                ? static_cast<Entry*>(hdr)->mAssertions
-                : nullptr;
+            PLDHashEntryHdr* hdr =
+                PL_DHashTableSearch(mNextAssertion->u.hash.mPropertyHash,
+                                    aProperty);
+            mNextAssertion =
+                hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
         }
     }
     else {
         mNextAssertion = mDataSource->GetReverseArcs(mTarget);
     }
 
     // Add an owning reference from the enumerator
     if (mNextAssertion)
@@ -975,20 +971,19 @@ InMemoryDataSource::GetTarget(nsIRDFReso
         return NS_ERROR_NULL_POINTER;
 
     NS_PRECONDITION(target != nullptr, "null ptr");
     if (! target)
         return NS_ERROR_NULL_POINTER;
 
     Assertion *as = GetForwardArcs(source);
     if (as && as->mHashEntry) {
-        PLDHashEntryHdr* hdr = PL_DHashTableLookup(as->u.hash.mPropertyHash, property);
-        Assertion* val = PL_DHASH_ENTRY_IS_BUSY(hdr)
-            ? static_cast<Entry*>(hdr)->mAssertions
-            : nullptr;
+        PLDHashEntryHdr* hdr =
+            PL_DHashTableSearch(as->u.hash.mPropertyHash, property);
+        Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
         while (val) {
             if (tv == val->u.as.mTruthValue) {
                 *target = val->u.as.mTarget;
                 NS_IF_ADDREF(*target);
                 return NS_OK;
             }
             val = val->mNext;
         }
@@ -1021,20 +1016,19 @@ InMemoryDataSource::HasAssertion(nsIRDFR
     if (! property)
         return NS_ERROR_NULL_POINTER;
 
     if (! target)
         return NS_ERROR_NULL_POINTER;
 
     Assertion *as = GetForwardArcs(source);
     if (as && as->mHashEntry) {
-        PLDHashEntryHdr* hdr = PL_DHashTableLookup(as->u.hash.mPropertyHash, property);
-        Assertion* val = PL_DHASH_ENTRY_IS_BUSY(hdr)
-            ? static_cast<Entry*>(hdr)->mAssertions
-            : nullptr;
+        PLDHashEntryHdr* hdr =
+            PL_DHashTableSearch(as->u.hash.mPropertyHash, property);
+        Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
         while (val) {
             if ((val->u.as.mTarget == target) && (tv == (val->u.as.mTruthValue))) {
                 *hasAssertion = true;
                 return NS_OK;
             }
             val = val->mNext;
         }
     }
@@ -1134,20 +1128,19 @@ InMemoryDataSource::LockedAssert(nsIRDFR
 #endif
 
     Assertion* next = GetForwardArcs(aSource);
     Assertion* prev = next;
     Assertion* as = nullptr;
 
     bool    haveHash = (next) ? next->mHashEntry : false;
     if (haveHash) {
-        PLDHashEntryHdr* hdr = PL_DHashTableLookup(next->u.hash.mPropertyHash, aProperty);
-        Assertion* val = PL_DHASH_ENTRY_IS_BUSY(hdr)
-            ? static_cast<Entry*>(hdr)->mAssertions
-            : nullptr;
+        PLDHashEntryHdr* hdr =
+            PL_DHashTableSearch(next->u.hash.mPropertyHash, aProperty);
+        Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
         while (val) {
             if (val->u.as.mTarget == aTarget) {
                 // Wow, we already had the assertion. Make sure that the
                 // truth values are correct and bail.
                 val->u.as.mTruthValue = aTruthValue;
                 return NS_OK;
             }
             val = val->mNext;
@@ -1175,21 +1168,20 @@ InMemoryDataSource::LockedAssert(nsIRDFR
     if (! as)
         return NS_ERROR_OUT_OF_MEMORY;
 
     // Add the datasource's owning reference.
     as->AddRef();
 
     if (haveHash)
     {
-        PLDHashEntryHdr* hdr = PL_DHashTableLookup(next->u.hash.mPropertyHash,
-            aProperty);
-        Assertion *asRef = PL_DHASH_ENTRY_IS_BUSY(hdr)
-            ? static_cast<Entry*>(hdr)->mAssertions
-            : nullptr;
+        PLDHashEntryHdr* hdr =
+            PL_DHashTableSearch(next->u.hash.mPropertyHash, aProperty);
+        Assertion *asRef =
+            hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
         if (asRef)
         {
             as->mNext = asRef->mNext;
             asRef->mNext = as;
         }
         else
         {
             hdr = PL_DHashTableAdd(next->u.hash.mPropertyHash, aProperty);
@@ -1276,21 +1268,19 @@ InMemoryDataSource::LockedUnassert(nsIRD
 
     Assertion* next = GetForwardArcs(aSource);
     Assertion* prev = next;
     Assertion* root = next;
     Assertion* as = nullptr;
 
     bool    haveHash = (next) ? next->mHashEntry : false;
     if (haveHash) {
-        PLDHashEntryHdr* hdr = PL_DHashTableLookup(next->u.hash.mPropertyHash,
-            aProperty);
-        prev = next = PL_DHASH_ENTRY_IS_BUSY(hdr)
-            ? static_cast<Entry*>(hdr)->mAssertions
-            : nullptr;
+        PLDHashEntryHdr* hdr =
+            PL_DHashTableSearch(next->u.hash.mPropertyHash, aProperty);
+        prev = next = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
         bool first = true;
         while (next) {
             if (aTarget == next->u.as.mTarget) {
                 break;
             }
             first = false;
             prev = next;
             next = next->mNext;
@@ -1579,21 +1569,19 @@ InMemoryDataSource::HasArcIn(nsIRDFNode 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 InMemoryDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, bool *result)
 {
     Assertion* ass = GetForwardArcs(aSource);
     if (ass && ass->mHashEntry) {
-        PLDHashEntryHdr* hdr = PL_DHashTableLookup(ass->u.hash.mPropertyHash,
-            aArc);
-        Assertion* val = PL_DHASH_ENTRY_IS_BUSY(hdr)
-            ? static_cast<Entry*>(hdr)->mAssertions
-            : nullptr;
+        PLDHashEntryHdr* hdr =
+            PL_DHashTableSearch(ass->u.hash.mPropertyHash, aArc);
+        Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
         if (val) {
             *result = true;
             return NS_OK;
         }
         ass = ass->mNext;
     }
     while (ass) {
         nsIRDFResource* elbow = ass->u.as.mProperty;
@@ -1740,21 +1728,18 @@ InMemoryDataSource::EnsureFastContainmen
 
     // mutate references of existing forward assertions into this hash
     PLDHashTable *table = hashAssertion->u.hash.mPropertyHash;
     Assertion *nextRef;
     while(first) {
         nextRef = first->mNext;
         nsIRDFResource *prop = first->u.as.mProperty;
 
-        PLDHashEntryHdr* hdr = PL_DHashTableLookup(table,
-            prop);
-        Assertion* val = PL_DHASH_ENTRY_IS_BUSY(hdr)
-            ? static_cast<Entry*>(hdr)->mAssertions
-            : nullptr;
+        PLDHashEntryHdr* hdr = PL_DHashTableSearch(table, prop);
+        Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
         if (val) {
             first->mNext = val->mNext;
             val->mNext = first;
         }
         else {
             PLDHashEntryHdr* hdr = PL_DHashTableAdd(table, prop);
             if (hdr) {
                 Entry* entry = static_cast<Entry*>(hdr);
@@ -1805,21 +1790,19 @@ InMemoryDataSource::Mark(nsIRDFResource*
         return NS_ERROR_NULL_POINTER;
 
     NS_PRECONDITION(aTarget != nullptr, "null ptr");
     if (! aTarget)
         return NS_ERROR_NULL_POINTER;
 
     Assertion *as = GetForwardArcs(aSource);
     if (as && as->mHashEntry) {
-        PLDHashEntryHdr* hdr = PL_DHashTableLookup(as->u.hash.mPropertyHash,
-            aProperty);
-        Assertion* val = PL_DHASH_ENTRY_IS_BUSY(hdr)
-            ? static_cast<Entry*>(hdr)->mAssertions
-            : nullptr;
+        PLDHashEntryHdr* hdr =
+            PL_DHashTableSearch(as->u.hash.mPropertyHash, aProperty);
+        Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr;
         while (val) {
             if ((val->u.as.mTarget == aTarget) &&
                 (aTruthValue == (val->u.as.mTruthValue))) {
 
                 // found it! so mark it.
                 as->Mark();
                 *aDidMark = true;
 
@@ -1941,18 +1924,18 @@ InMemoryDataSource::SweepForwardArcsEntr
             }
             else {
                 // it's the first one. update the hashtable entry.
                 entry->mAssertions = next;
             }
 
             // remove from the reverse arcs
             PLDHashEntryHdr* hdr =
-                PL_DHashTableLookup(info->mReverseArcs, as->u.as.mTarget);
-            NS_ASSERTION(PL_DHASH_ENTRY_IS_BUSY(hdr), "no assertion in reverse arcs");
+                PL_DHashTableSearch(info->mReverseArcs, as->u.as.mTarget);
+            NS_ASSERTION(hdr, "no assertion in reverse arcs");
 
             Entry* rentry = static_cast<Entry*>(hdr);
             Assertion* ras = rentry->mAssertions;
             Assertion* rprev = nullptr;
             while (ras) {
                 if (ras == as) {
                     if (rprev) {
                         rprev->u.as.mInvNext = ras->u.as.mInvNext;
--- a/rdf/base/nsRDFService.cpp
+++ b/rdf/base/nsRDFService.cpp
@@ -856,20 +856,18 @@ RDFServiceImpl::GetResource(const nsACSt
     if (aURI.IsEmpty())
         return NS_ERROR_INVALID_ARG;
 
     const nsAFlatCString& flatURI = PromiseFlatCString(aURI);
     PR_LOG(gLog, PR_LOG_DEBUG, ("rdfserv get-resource %s", flatURI.get()));
 
     // First, check the cache to see if we've already created and
     // registered this thing.
-    PLDHashEntryHdr *hdr =
-        PL_DHashTableLookup(&mResources, flatURI.get());
-
-    if (PL_DHASH_ENTRY_IS_BUSY(hdr)) {
+    PLDHashEntryHdr *hdr = PL_DHashTableSearch(&mResources, flatURI.get());
+    if (hdr) {
         ResourceHashEntry *entry = static_cast<ResourceHashEntry *>(hdr);
         NS_ADDREF(*aResource = entry->mResource);
         return NS_OK;
     }
 
     // Nope. So go to the repository to create it.
 
     // Compute the scheme of the URI. Scan forward until we either:
@@ -1026,37 +1024,33 @@ RDFServiceImpl::GetLiteral(const char16_
     if (! aValue)
         return NS_ERROR_NULL_POINTER;
 
     NS_PRECONDITION(aLiteral != nullptr, "null ptr");
     if (! aLiteral)
         return NS_ERROR_NULL_POINTER;
 
     // See if we have one already cached
-    PLDHashEntryHdr *hdr =
-        PL_DHashTableLookup(&mLiterals, aValue);
-
-    if (PL_DHASH_ENTRY_IS_BUSY(hdr)) {
+    PLDHashEntryHdr *hdr = PL_DHashTableSearch(&mLiterals, aValue);
+    if (hdr) {
         LiteralHashEntry *entry = static_cast<LiteralHashEntry *>(hdr);
         NS_ADDREF(*aLiteral = entry->mLiteral);
         return NS_OK;
     }
 
     // Nope. Create a new one
     return LiteralImpl::Create(aValue, aLiteral);
 }
 
 NS_IMETHODIMP
 RDFServiceImpl::GetDateLiteral(PRTime aTime, nsIRDFDate** aResult)
 {
     // See if we have one already cached
-    PLDHashEntryHdr *hdr =
-        PL_DHashTableLookup(&mDates, &aTime);
-
-    if (PL_DHASH_ENTRY_IS_BUSY(hdr)) {
+    PLDHashEntryHdr *hdr = PL_DHashTableSearch(&mDates, &aTime);
+    if (hdr) {
         DateHashEntry *entry = static_cast<DateHashEntry *>(hdr);
         NS_ADDREF(*aResult = entry->mDate);
         return NS_OK;
     }
 
     DateImpl* result = new DateImpl(aTime);
     if (! result)
         return NS_ERROR_OUT_OF_MEMORY;
@@ -1064,20 +1058,18 @@ RDFServiceImpl::GetDateLiteral(PRTime aT
     NS_ADDREF(*aResult = result);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 RDFServiceImpl::GetIntLiteral(int32_t aInt, nsIRDFInt** aResult)
 {
     // See if we have one already cached
-    PLDHashEntryHdr *hdr =
-        PL_DHashTableLookup(&mInts, &aInt);
-
-    if (PL_DHASH_ENTRY_IS_BUSY(hdr)) {
+    PLDHashEntryHdr *hdr = PL_DHashTableSearch(&mInts, &aInt);
+    if (hdr) {
         IntHashEntry *entry = static_cast<IntHashEntry *>(hdr);
         NS_ADDREF(*aResult = entry->mInt);
         return NS_OK;
     }
 
     IntImpl* result = new IntImpl(aInt);
     if (! result)
         return NS_ERROR_OUT_OF_MEMORY;
@@ -1087,20 +1079,18 @@ RDFServiceImpl::GetIntLiteral(int32_t aI
 }
 
 NS_IMETHODIMP
 RDFServiceImpl::GetBlobLiteral(const uint8_t *aBytes, int32_t aLength,
                                nsIRDFBlob **aResult)
 {
     BlobImpl::Data key = { aLength, const_cast<uint8_t *>(aBytes) };
 
-    PLDHashEntryHdr *hdr =
-        PL_DHashTableLookup(&mBlobs, &key);
-
-    if (PL_DHASH_ENTRY_IS_BUSY(hdr)) {
+    PLDHashEntryHdr *hdr = PL_DHashTableSearch(&mBlobs, &key);
+    if (hdr) {
         BlobHashEntry *entry = static_cast<BlobHashEntry *>(hdr);
         NS_ADDREF(*aResult = entry->mBlob);
         return NS_OK;
     }
 
     BlobImpl *result = new BlobImpl(aBytes, aLength);
     if (! result)
         return NS_ERROR_OUT_OF_MEMORY;
@@ -1150,20 +1140,18 @@ RDFServiceImpl::RegisterResource(nsIRDFR
     rv = aResource->GetValueConst(&uri);
     NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get URI from resource");
     if (NS_FAILED(rv)) return rv;
 
     NS_ASSERTION(uri != nullptr, "resource has no URI");
     if (! uri)
         return NS_ERROR_NULL_POINTER;
 
-    PLDHashEntryHdr *hdr =
-        PL_DHashTableLookup(&mResources, uri);
-
-    if (PL_DHASH_ENTRY_IS_BUSY(hdr)) {
+    PLDHashEntryHdr *hdr = PL_DHashTableSearch(&mResources, uri);
+    if (hdr) {
         if (!aReplace) {
             NS_WARNING("resource already registered, and replace not specified");
             return NS_ERROR_FAILURE;    // already registered
         }
 
         // N.B., we do _not_ release the original resource because we
         // only ever held a weak reference to it. We simply replace
         // it.
@@ -1211,17 +1199,17 @@ RDFServiceImpl::UnregisterResource(nsIRD
     if (! uri)
         return NS_ERROR_UNEXPECTED;
 
     PR_LOG(gLog, PR_LOG_DEBUG,
            ("rdfserv unregister-resource [%p] %s",
             aResource, (const char*) uri));
 
 #ifdef DEBUG
-    if (PL_DHASH_ENTRY_IS_FREE(PL_DHashTableLookup(&mResources, uri)))
+    if (!PL_DHashTableSearch(&mResources, uri))
         NS_WARNING("resource was never registered");
 #endif
 
     PL_DHashTableRemove(&mResources, uri);
     return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -1403,23 +1391,20 @@ RDFServiceImpl::GetDataSource(const char
 ////////////////////////////////////////////////////////////////////////
 
 nsresult
 RDFServiceImpl::RegisterLiteral(nsIRDFLiteral* aLiteral)
 {
     const char16_t* value;
     aLiteral->GetValueConst(&value);
 
-    NS_ASSERTION(PL_DHASH_ENTRY_IS_FREE(PL_DHashTableLookup(&mLiterals,
-                                                            value)),
+    NS_ASSERTION(!PL_DHashTableSearch(&mLiterals, value),
                  "literal already registered");
 
-    PLDHashEntryHdr *hdr =
-        PL_DHashTableAdd(&mLiterals, value);
-
+    PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mLiterals, value);
     if (! hdr)
         return NS_ERROR_OUT_OF_MEMORY;
 
     LiteralHashEntry *entry = static_cast<LiteralHashEntry *>(hdr);
 
     // N.B., we only hold a weak reference to the literal: that
     // way, the literal can be destroyed when the last refcount
     // goes away. The single addref that the CreateLiteral() call
@@ -1436,18 +1421,17 @@ RDFServiceImpl::RegisterLiteral(nsIRDFLi
 
 
 nsresult
 RDFServiceImpl::UnregisterLiteral(nsIRDFLiteral* aLiteral)
 {
     const char16_t* value;
     aLiteral->GetValueConst(&value);
 
-    NS_ASSERTION(PL_DHASH_ENTRY_IS_BUSY(PL_DHashTableLookup(&mLiterals,
-                                                            value)),
+    NS_ASSERTION(PL_DHashTableSearch(&mLiterals, value),
                  "literal was never registered");
 
     PL_DHashTableRemove(&mLiterals, value);
 
     // N.B. that we _don't_ release the literal: we only held a weak
     // reference to it in the hashtable.
     PR_LOG(gLog, PR_LOG_DEBUG,
            ("rdfserv unregister-literal [%p] %s",
@@ -1459,23 +1443,20 @@ RDFServiceImpl::UnregisterLiteral(nsIRDF
 //----------------------------------------------------------------------
 
 nsresult
 RDFServiceImpl::RegisterInt(nsIRDFInt* aInt)
 {
     int32_t value;
     aInt->GetValue(&value);
 
-    NS_ASSERTION(PL_DHASH_ENTRY_IS_FREE(PL_DHashTableLookup(&mInts,
-                                                            &value)),
+    NS_ASSERTION(!PL_DHashTableSearch(&mInts, &value),
                  "int already registered");
 
-    PLDHashEntryHdr *hdr =
-        PL_DHashTableAdd(&mInts, &value);
-
+    PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mInts, &value);
     if (! hdr)
         return NS_ERROR_OUT_OF_MEMORY;
 
     IntHashEntry *entry = static_cast<IntHashEntry *>(hdr);
 
     // N.B., we only hold a weak reference to the literal: that
     // way, the literal can be destroyed when the last refcount
     // goes away. The single addref that the CreateInt() call
@@ -1492,18 +1473,17 @@ RDFServiceImpl::RegisterInt(nsIRDFInt* a
 
 
 nsresult
 RDFServiceImpl::UnregisterInt(nsIRDFInt* aInt)
 {
     int32_t value;
     aInt->GetValue(&value);
 
-    NS_ASSERTION(PL_DHASH_ENTRY_IS_BUSY(PL_DHashTableLookup(&mInts,
-                                                            &value)),
+    NS_ASSERTION(PL_DHashTableSearch(&mInts, &value),
                  "int was never registered");
 
     PL_DHashTableRemove(&mInts, &value);
 
     // N.B. that we _don't_ release the literal: we only held a weak
     // reference to it in the hashtable.
     PR_LOG(gLog, PR_LOG_DEBUG,
            ("rdfserv unregister-int [%p] %d",
@@ -1515,23 +1495,20 @@ RDFServiceImpl::UnregisterInt(nsIRDFInt*
 //----------------------------------------------------------------------
 
 nsresult
 RDFServiceImpl::RegisterDate(nsIRDFDate* aDate)
 {
     PRTime value;
     aDate->GetValue(&value);
 
-    NS_ASSERTION(PL_DHASH_ENTRY_IS_FREE(PL_DHashTableLookup(&mDates,
-                                                            &value)),
+    NS_ASSERTION(!PL_DHashTableSearch(&mDates, &value),
                  "date already registered");
 
-    PLDHashEntryHdr *hdr =
-        PL_DHashTableAdd(&mDates, &value);
-
+    PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mDates, &value);
     if (! hdr)
         return NS_ERROR_OUT_OF_MEMORY;
 
     DateHashEntry *entry = static_cast<DateHashEntry *>(hdr);
 
     // N.B., we only hold a weak reference to the literal: that
     // way, the literal can be destroyed when the last refcount
     // goes away. The single addref that the CreateDate() call
@@ -1548,41 +1525,37 @@ RDFServiceImpl::RegisterDate(nsIRDFDate*
 
 
 nsresult
 RDFServiceImpl::UnregisterDate(nsIRDFDate* aDate)
 {
     PRTime value;
     aDate->GetValue(&value);
 
-    NS_ASSERTION(PL_DHASH_ENTRY_IS_BUSY(PL_DHashTableLookup(&mDates,
-                                                            &value)),
+    NS_ASSERTION(PL_DHashTableSearch(&mDates, &value),
                  "date was never registered");
 
     PL_DHashTableRemove(&mDates, &value);
 
     // N.B. that we _don't_ release the literal: we only held a weak
     // reference to it in the hashtable.
     PR_LOG(gLog, PR_LOG_DEBUG,
            ("rdfserv unregister-date [%p] %ld",
             aDate, value));
 
     return NS_OK;
 }
 
 nsresult
 RDFServiceImpl::RegisterBlob(BlobImpl *aBlob)
 {
-    NS_ASSERTION(PL_DHASH_ENTRY_IS_FREE(PL_DHashTableLookup(&mBlobs,
-                                                            &aBlob->mData)),
+    NS_ASSERTION(!PL_DHashTableSearch(&mBlobs, &aBlob->mData),
                  "blob already registered");
 
-    PLDHashEntryHdr *hdr = 
-        PL_DHashTableAdd(&mBlobs, &aBlob->mData);
-
+    PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mBlobs, &aBlob->mData);
     if (! hdr)
         return NS_ERROR_OUT_OF_MEMORY;
 
     BlobHashEntry *entry = static_cast<BlobHashEntry *>(hdr);
 
     // N.B., we only hold a weak reference to the literal: that
     // way, the literal can be destroyed when the last refcount
     // goes away. The single addref that the CreateInt() call
@@ -1594,22 +1567,21 @@ RDFServiceImpl::RegisterBlob(BlobImpl *a
             aBlob, aBlob->mData.mBytes));
 
     return NS_OK;
 }
 
 nsresult
 RDFServiceImpl::UnregisterBlob(BlobImpl *aBlob)
 {
-    NS_ASSERTION(PL_DHASH_ENTRY_IS_BUSY(PL_DHashTableLookup(&mBlobs,
-                                                            &aBlob->mData)),
+    NS_ASSERTION(PL_DHashTableSearch(&mBlobs, &aBlob->mData),
                  "blob was never registered");
 
     PL_DHashTableRemove(&mBlobs, &aBlob->mData);
- 
+
      // N.B. that we _don't_ release the literal: we only held a weak
      // reference to it in the hashtable.
     PR_LOG(gLog, PR_LOG_DEBUG,
            ("rdfserv unregister-blob [%p] %s",
             aBlob, aBlob->mData.mBytes));
 
     return NS_OK;
 }
--- a/security/manager/boot/src/nsSecureBrowserUIImpl.cpp
+++ b/security/manager/boot/src/nsSecureBrowserUIImpl.cpp
@@ -963,21 +963,18 @@ nsSecureBrowserUIImpl::OnStateChange(nsI
   bool requestHasTransferedData = false;
 
   if (aProgressStateFlags & STATE_STOP
       &&
       aProgressStateFlags & STATE_IS_REQUEST)
   {
     { /* scope for the ReentrantMonitorAutoEnter */
       ReentrantMonitorAutoEnter lock(mReentrantMonitor);
-      PLDHashEntryHdr *entry = PL_DHashTableLookup(&mTransferringRequests, aRequest);
-      if (PL_DHASH_ENTRY_IS_BUSY(entry))
-      {
+      if (PL_DHashTableSearch(&mTransferringRequests, aRequest)) {
         PL_DHashTableRemove(&mTransferringRequests, aRequest);
-
         requestHasTransferedData = true;
       }
     }
 
     if (!requestHasTransferedData) {
       // Because image loads doesn't support any TRANSFERRING notifications but
       // only START and STOP we must ask them directly whether content was
       // transferred.  See bug 432685 for details.
--- a/uriloader/base/nsDocLoader.cpp
+++ b/uriloader/base/nsDocLoader.cpp
@@ -1349,29 +1349,18 @@ nsresult nsDocLoader::AddRequestInfo(nsI
 
 void nsDocLoader::RemoveRequestInfo(nsIRequest *aRequest)
 {
   PL_DHashTableRemove(&mRequestInfoHash, aRequest);
 }
 
 nsDocLoader::nsRequestInfo* nsDocLoader::GetRequestInfo(nsIRequest* aRequest)
 {
-  nsRequestInfo* info =
-    static_cast<nsRequestInfo*>
-               (PL_DHashTableLookup(&mRequestInfoHash, aRequest));
-
-  if (PL_DHASH_ENTRY_IS_FREE(info)) {
-    // Nothing found in the hash, return null.
-
-    return nullptr;
-  }
-
-  // Return what we found in the hash...
-
-  return info;
+  return static_cast<nsRequestInfo*>
+                    (PL_DHashTableSearch(&mRequestInfoHash, aRequest));
 }
 
 // PLDHashTable enumeration callback that just removes every entry
 // from the hash.
 static PLDHashOperator
 RemoveInfoCallback(PLDHashTable *table, PLDHashEntryHdr *hdr, uint32_t number,
                    void *arg)
 {
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -887,21 +887,18 @@ public:
     *aWeakMapsSize = mWeakMaps.SizeOfExcludingThis(aMallocSizeOf);
   }
 };
 
 PtrInfo*
 CCGraph::FindNode(void* aPtr)
 {
   PtrToNodeEntry* e =
-    static_cast<PtrToNodeEntry*>(PL_DHashTableLookup(&mPtrToNodeMap, aPtr));
-  if (!PL_DHASH_ENTRY_IS_BUSY(e)) {
-    return nullptr;
-  }
-  return e->mNode;
+    static_cast<PtrToNodeEntry*>(PL_DHashTableSearch(&mPtrToNodeMap, aPtr));
+  return e ? e->mNode : nullptr;
 }
 
 PtrToNodeEntry*
 CCGraph::AddNodeToMap(void* aPtr)
 {
   JS::AutoSuppressGCAnalysis suppress;
   PtrToNodeEntry* e =
     static_cast<PtrToNodeEntry*>(PL_DHashTableAdd(&mPtrToNodeMap, aPtr));
--- a/xpcom/ds/nsPersistentProperties.cpp
+++ b/xpcom/ds/nsPersistentProperties.cpp
@@ -552,19 +552,19 @@ nsPersistentProperties::Save(nsIOutputSt
 
 NS_IMETHODIMP
 nsPersistentProperties::GetStringProperty(const nsACString& aKey,
                                           nsAString& aValue)
 {
   const nsAFlatCString&  flatKey = PromiseFlatCString(aKey);
 
   PropertyTableEntry* entry = static_cast<PropertyTableEntry*>(
-    PL_DHashTableLookup(&mTable, flatKey.get()));
+    PL_DHashTableSearch(&mTable, flatKey.get()));
 
-  if (PL_DHASH_ENTRY_IS_FREE(entry)) {
+  if (!entry) {
     return NS_ERROR_FAILURE;
   }
 
   aValue = entry->mValue;
   return NS_OK;
 }
 
 static PLDHashOperator
@@ -623,19 +623,17 @@ NS_IMETHODIMP
 nsPersistentProperties::Undefine(const char* aProp)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 nsPersistentProperties::Has(const char* aProp, bool* aResult)
 {
-  PropertyTableEntry* entry = static_cast<PropertyTableEntry*>(
-    PL_DHashTableLookup(&mTable, aProp));
-  *aResult = (entry && PL_DHASH_ENTRY_IS_BUSY(entry));
+  *aResult = !!PL_DHashTableSearch(&mTable, aProp);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsPersistentProperties::GetKeys(uint32_t* aCount, char*** aKeys)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
--- a/xpcom/ds/nsStaticNameTable.cpp
+++ b/xpcom/ds/nsStaticNameTable.cpp
@@ -186,40 +186,34 @@ nsStaticCaseInsensitiveNameTable::Lookup
 {
   NS_ASSERTION(mNameArray, "not inited");
   NS_ASSERTION(mNameTable.IsInitialized(), "not inited");
 
   const nsAFlatCString& str = PromiseFlatCString(aName);
 
   NameTableKey key(&str);
   NameTableEntry* entry =
-    static_cast<NameTableEntry*>(PL_DHashTableLookup(&mNameTable, &key));
-  if (PL_DHASH_ENTRY_IS_FREE(entry)) {
-    return nsStaticCaseInsensitiveNameTable::NOT_FOUND;
-  }
+    static_cast<NameTableEntry*>(PL_DHashTableSearch(&mNameTable, &key));
 
-  return entry->mIndex;
+  return entry ? entry->mIndex : nsStaticCaseInsensitiveNameTable::NOT_FOUND;
 }
 
 int32_t
 nsStaticCaseInsensitiveNameTable::Lookup(const nsAString& aName)
 {
   NS_ASSERTION(mNameArray, "not inited");
   NS_ASSERTION(mNameTable.IsInitialized(), "not inited");
 
   const nsAFlatString& str = PromiseFlatString(aName);
 
   NameTableKey key(&str);
   NameTableEntry* entry =
-    static_cast<NameTableEntry*>(PL_DHashTableLookup(&mNameTable, &key));
-  if (PL_DHASH_ENTRY_IS_FREE(entry)) {
-    return nsStaticCaseInsensitiveNameTable::NOT_FOUND;
-  }
+    static_cast<NameTableEntry*>(PL_DHashTableSearch(&mNameTable, &key));
 
-  return entry->mIndex;
+  return entry ? entry->mIndex : nsStaticCaseInsensitiveNameTable::NOT_FOUND;
 }
 
 const nsAFlatCString&
 nsStaticCaseInsensitiveNameTable::GetStringValue(int32_t aIndex)
 {
   NS_ASSERTION(mNameArray, "not inited");
   NS_ASSERTION(mNameTable.IsInitialized(), "not inited");
 
--- a/xpcom/glue/nsTHashtable.h
+++ b/xpcom/glue/nsTHashtable.h
@@ -124,20 +124,19 @@ public:
    * @return    pointer to the entry class, if the key exists; nullptr if the
    *            key doesn't exist
    */
   EntryType* GetEntry(KeyType aKey) const
   {
     NS_ASSERTION(mTable.IsInitialized(),
                  "nsTHashtable was not initialized properly.");
 
-    EntryType* entry = static_cast<EntryType*>(
-      PL_DHashTableLookup(const_cast<PLDHashTable*>(&mTable),
+    return static_cast<EntryType*>(
+      PL_DHashTableSearch(const_cast<PLDHashTable*>(&mTable),
                           EntryType::KeyToPointer(aKey)));
-    return PL_DHASH_ENTRY_IS_BUSY(entry) ? entry : nullptr;
   }
 
   /**
    * Return true if an entry for the given key exists, false otherwise.
    * @param     aKey the key to retrieve
    * @return    true if the key exists, false if the key doesn't exist
    */
   bool Contains(KeyType aKey) const { return !!GetEntry(aKey); }
--- a/xpcom/glue/pldhash.cpp
+++ b/xpcom/glue/pldhash.cpp
@@ -551,16 +551,23 @@ PLDHashTable::Lookup(const void* aKey)
   PLDHashEntryHdr* entry = SearchTable(aKey, keyHash, /* isAdd = */ false);
 
   DECREMENT_RECURSION_LEVEL(this);
 
   return entry;
 }
 
 MOZ_ALWAYS_INLINE PLDHashEntryHdr*
+PLDHashTable::Search(const void* aKey)
+{
+  PLDHashEntryHdr* entry = Lookup(aKey);
+  return PL_DHASH_ENTRY_IS_BUSY(entry) ? entry : nullptr;
+}
+
+MOZ_ALWAYS_INLINE PLDHashEntryHdr*
 PLDHashTable::Add(const void* aKey)
 {
   PLDHashNumber keyHash;
   PLDHashEntryHdr* entry;
 
   MOZ_ASSERT(mRecursionLevel == 0);
   INCREMENT_RECURSION_LEVEL(this);
 
@@ -656,16 +663,22 @@ PLDHashTable::Remove(const void* aKey)
 
 PLDHashEntryHdr* PL_DHASH_FASTCALL
 PL_DHashTableLookup(PLDHashTable* aTable, const void* aKey)
 {
   return aTable->Lookup(aKey);
 }
 
 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)
 {
   return aTable->Add(aKey);
 }
 
 void PL_DHASH_FASTCALL
 PL_DHashTableRemove(PLDHashTable* aTable, const void* aKey)
 {
--- a/xpcom/glue/pldhash.h
+++ b/xpcom/glue/pldhash.h
@@ -254,16 +254,17 @@ public:
   uint32_t Generation() const { return mGeneration; }
 
   bool Init(const PLDHashTableOps* aOps, uint32_t aEntrySize,
             const mozilla::fallible_t&, uint32_t aLength);
 
   void Finish();
 
   PLDHashEntryHdr* Lookup(const void* aKey);
+  PLDHashEntryHdr* Search(const void* aKey);
   PLDHashEntryHdr* Add(const void* aKey);
   void Remove(const void* aKey);
 
   void RawRemove(PLDHashEntryHdr* aEntry);
 
   uint32_t Enumerate(PLDHashEnumerator aEtor, void* aArg);
 
   size_t SizeOfIncludingThis(
@@ -486,16 +487,27 @@ void PL_DHashTableFinish(PLDHashTable* a
  *
  * If PL_DHASH_ENTRY_IS_BUSY(entry) is true, key was found and it identifies
  * entry.  If PL_DHASH_ENTRY_IS_FREE(entry) is true, key was not found.
  */
 PLDHashEntryHdr* PL_DHASH_FASTCALL
 PL_DHashTableLookup(PLDHashTable* aTable, const void* aKey);
 
 /*
+ * To lookup a key in table, call:
+ *
+ *  entry = PL_DHashTableSearch(table, key);
+ *
+ * If |entry| is non-null, key was found and it identifies entry.  If |entry|
+ * is null, key was not found.
+ */
+PLDHashEntryHdr* PL_DHASH_FASTCALL
+PL_DHashTableSearch(PLDHashTable* aTable, const void* aKey);
+
+/*
  * To add an entry identified by key to table, call:
  *
  *  entry = PL_DHashTableAdd(table, key);
  *
  * If entry is null upon return, then either the table is severely overloaded,
  * and memory can't be allocated for entry storage. Or if
  * aTable->mOps->initEntry is non-null, the aTable->mOps->initEntry op may have
  * returned false.