Bug 1370700 part 1 - Use mAttributeCache.LookupRemoveIf() to avoid a second hashtable lookup for Remove(). r=froydnj
authorMats Palmgren <mats@mozilla.com>
Wed, 07 Jun 2017 20:03:19 +0200
changeset 410857 883902e4d9992a9d4a6dc48fae0e8f5fa72c80a5
parent 410856 3c9a4dbc3409494e745ad9afa04bf3f4d2c35be9
child 410858 eb418afc24afb12ec0d8bca4e9aa2068db384f2a
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1370700
milestone55.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 1370700 part 1 - Use mAttributeCache.LookupRemoveIf() to avoid a second hashtable lookup for Remove(). r=froydnj MozReview-Commit-ID: CrIb6DcE1D7
dom/base/nsDOMAttributeMap.cpp
--- a/dom/base/nsDOMAttributeMap.cpp
+++ b/dom/base/nsDOMAttributeMap.cpp
@@ -113,24 +113,21 @@ nsDOMAttributeMap::SetOwnerDocument(nsID
   }
   return NS_OK;
 }
 
 void
 nsDOMAttributeMap::DropAttribute(int32_t aNamespaceID, nsIAtom* aLocalName)
 {
   nsAttrKey attr(aNamespaceID, aLocalName);
-  Attr *node = mAttributeCache.GetWeak(attr);
-  if (node) {
-    // Break link to map
-    node->SetMap(nullptr);
-
-    // Remove from cache
-    mAttributeCache.Remove(attr);
-  }
+  mAttributeCache.LookupRemoveIf(attr,
+    [] (Attr* aNode) {
+      aNode->SetMap(nullptr); // break link to map
+      return true; // remove from cache
+    });
 }
 
 Attr*
 nsDOMAttributeMap::GetAttribute(mozilla::dom::NodeInfo* aNodeInfo)
 {
   NS_ASSERTION(aNodeInfo, "GetAttribute() called with aNodeInfo == nullptr!");
 
   nsAttrKey attr(aNodeInfo->NamespaceID(), aNodeInfo->NameAtom());