Bug 678820 - nsAttrAndChildArray shouldn't ask for a new slot in the mapped attributes object when it is not needed. f=bz r=sicking
authorMounir Lamouri <mounir.lamouri@gmail.com>
Wed, 24 Aug 2011 19:27:52 +0200
changeset 77138 22e2f80c2983978e9d2a6ef5b131bc75e8913263
parent 77137 206ab0f10adf0e078a2543aa3de42844725af676
child 77139 45bce33d2bd7001fe0bb53ead42a4ecc6752d9b1
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs678820
milestone9.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 678820 - nsAttrAndChildArray shouldn't ask for a new slot in the mapped attributes object when it is not needed. f=bz r=sicking
content/base/src/nsAttrAndChildArray.cpp
--- a/content/base/src/nsAttrAndChildArray.cpp
+++ b/content/base/src/nsAttrAndChildArray.cpp
@@ -570,17 +570,23 @@ nsAttrAndChildArray::IndexOfAttr(nsIAtom
 
 nsresult
 nsAttrAndChildArray::SetAndTakeMappedAttr(nsIAtom* aLocalName,
                                           nsAttrValue& aValue,
                                           nsMappedAttributeElement* aContent,
                                           nsHTMLStyleSheet* aSheet)
 {
   nsRefPtr<nsMappedAttributes> mapped;
-  nsresult rv = GetModifiableMapped(aContent, aSheet, PR_TRUE,
+
+  PRBool willAdd = PR_TRUE;
+  if (mImpl && mImpl->mMappedAttrs) {
+    willAdd = mImpl->mMappedAttrs->GetAttr(aLocalName) == nsnull;
+  }
+
+  nsresult rv = GetModifiableMapped(aContent, aSheet, willAdd,
                                     getter_AddRefs(mapped));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = mapped->SetAndTakeAttr(aLocalName, aValue);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return MakeMappedUnique(mapped);
 }