Title: [134163] trunk/Source/WebCore
- Revision
- 134163
- Author
- [email protected]
- Date
- 2012-11-10 14:35:46 -0800 (Sat, 10 Nov 2012)
Log Message
Don't detach from shared ElementAttributeData when overwriting attribute with identical value.
<http://webkit.org/b/101849>
Reviewed by Anders Carlsson.
Defer the mutableAttributeData() call in Element::setAttributeInternal() until the last
possible moment, to avoid unnecessarily detaching and cloning from attribute data.
120 kB progression on Membuster3.
* dom/Element.cpp:
(WebCore::Element::setAttributeInternal):
(WebCore::Element::addAttributeInternal):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (134162 => 134163)
--- trunk/Source/WebCore/ChangeLog 2012-11-10 21:56:15 UTC (rev 134162)
+++ trunk/Source/WebCore/ChangeLog 2012-11-10 22:35:46 UTC (rev 134163)
@@ -1,3 +1,19 @@
+2012-11-10 Andreas Kling <[email protected]>
+
+ Don't detach from shared ElementAttributeData when overwriting attribute with identical value.
+ <http://webkit.org/b/101849>
+
+ Reviewed by Anders Carlsson.
+
+ Defer the mutableAttributeData() call in Element::setAttributeInternal() until the last
+ possible moment, to avoid unnecessarily detaching and cloning from attribute data.
+
+ 120 kB progression on Membuster3.
+
+ * dom/Element.cpp:
+ (WebCore::Element::setAttributeInternal):
+ (WebCore::Element::addAttributeInternal):
+
2012-11-10 Simon Fraser <[email protected]>
Some minor optimizations in RenderLayer
Modified: trunk/Source/WebCore/dom/Element.cpp (134162 => 134163)
--- trunk/Source/WebCore/dom/Element.cpp 2012-11-10 21:56:15 UTC (rev 134162)
+++ trunk/Source/WebCore/dom/Element.cpp 2012-11-10 22:35:46 UTC (rev 134163)
@@ -711,30 +711,29 @@
inline void Element::setAttributeInternal(size_t index, const QualifiedName& name, const AtomicString& newValue, SynchronizationOfLazyAttribute inSynchronizationOfLazyAttribute)
{
- ElementAttributeData* attributeData = mutableAttributeData();
-
- Attribute* existingAttribute = index != notFound ? attributeData->attributeItem(index) : 0;
if (newValue.isNull()) {
- if (existingAttribute)
+ if (index != notFound)
removeAttributeInternal(index, inSynchronizationOfLazyAttribute);
return;
}
- if (!existingAttribute) {
+ if (index == notFound) {
addAttributeInternal(name, newValue, inSynchronizationOfLazyAttribute);
return;
}
if (!inSynchronizationOfLazyAttribute)
- willModifyAttribute(name, existingAttribute->value(), newValue);
+ willModifyAttribute(name, attributeItem(index)->value(), newValue);
- // If there is an Attr node hooked to this attribute, the Attr::setValue() call below
- // will write into the ElementAttributeData.
- // FIXME: Refactor this so it makes some sense.
- if (RefPtr<Attr> attrNode = attrIfExists(name))
- attrNode->setValue(newValue);
- else
- existingAttribute->setValue(newValue);
+ if (newValue != attributeItem(index)->value()) {
+ // If there is an Attr node hooked to this attribute, the Attr::setValue() call below
+ // will write into the ElementAttributeData.
+ // FIXME: Refactor this so it makes some sense.
+ if (RefPtr<Attr> attrNode = attrIfExists(name))
+ attrNode->setValue(newValue);
+ else
+ mutableAttributeData()->attributeItem(index)->setValue(newValue);
+ }
if (!inSynchronizationOfLazyAttribute)
didModifyAttribute(name, newValue);
@@ -1636,11 +1635,9 @@
void Element::addAttributeInternal(const QualifiedName& name, const AtomicString& value, SynchronizationOfLazyAttribute inSynchronizationOfLazyAttribute)
{
- ASSERT(m_attributeData);
- ASSERT(m_attributeData->isMutable());
if (!inSynchronizationOfLazyAttribute)
willModifyAttribute(name, nullAtom, value);
- m_attributeData->addAttribute(Attribute(name, value));
+ mutableAttributeData()->addAttribute(Attribute(name, value));
if (!inSynchronizationOfLazyAttribute)
didAddAttribute(name, value);
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes