Bug 1370700 part 2 - Use mAttributeCache.GetOrInsert() to avoid a second hashtable lookup for Put(). r=froydnj
authorMats Palmgren <mats@mozilla.com>
Wed, 07 Jun 2017 20:03:19 +0200
changeset 410858 eb418afc24afb12ec0d8bca4e9aa2068db384f2a
parent 410857 883902e4d9992a9d4a6dc48fae0e8f5fa72c80a5
child 410859 196bfa86b5a63c20f7f6fdf3e30d9ff3d8839de3
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 2 - Use mAttributeCache.GetOrInsert() to avoid a second hashtable lookup for Put(). r=froydnj MozReview-Commit-ID: BE6vztn6ljl
dom/base/nsDOMAttributeMap.cpp
--- a/dom/base/nsDOMAttributeMap.cpp
+++ b/dom/base/nsDOMAttributeMap.cpp
@@ -127,23 +127,23 @@ nsDOMAttributeMap::DropAttribute(int32_t
 
 Attr*
 nsDOMAttributeMap::GetAttribute(mozilla::dom::NodeInfo* aNodeInfo)
 {
   NS_ASSERTION(aNodeInfo, "GetAttribute() called with aNodeInfo == nullptr!");
 
   nsAttrKey attr(aNodeInfo->NamespaceID(), aNodeInfo->NameAtom());
 
-  Attr* node = mAttributeCache.GetWeak(attr);
+  RefPtr<Attr>& entryValue = mAttributeCache.GetOrInsert(attr);
+  Attr* node = entryValue;
   if (!node) {
+    // Newly inserted entry!
     RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
-    RefPtr<Attr> newAttr =
-      new Attr(this, ni.forget(), EmptyString());
-    mAttributeCache.Put(attr, newAttr);
-    node = newAttr;
+    entryValue = new Attr(this, ni.forget(), EmptyString());
+    node = entryValue;
   }
 
   return node;
 }
 
 Attr*
 nsDOMAttributeMap::NamedGetter(const nsAString& aAttrName, bool& aFound)
 {