- Revision
- 174428
- Author
- [email protected]
- Date
- 2014-10-08 03:42:01 -0700 (Wed, 08 Oct 2014)
Log Message
Merge r173783 - Minimize virtual function calls in MarkupAccumulator
https://bugs.webkit.org/show_bug.cgi?id=136957
Reviewed by Benjamin Poulain.
This patch minimizes the number of virtual function calls in
MarkupAccumulator by:
- De-virtualizing MarkupAccumulator::appendString(), which is never
overridden
- Having MarkupAccumulator::appendEndTag() virtual function take an
Element in argument instead of a Node, as it only applies to Element.
Also add a non-virtual overload that takes a Node in argument and
that does the isElementNode() check so that we don't need to explicitly
do the check at each call site.
No new tests, no behavior change.
* editing/MarkupAccumulator.cpp:
(WebCore::MarkupAccumulator::appendEndTag):
(WebCore::MarkupAccumulator::shouldSelfClose):
(WebCore::MarkupAccumulator::appendEndMarkup):
* editing/MarkupAccumulator.h:
(WebCore::MarkupAccumulator::appendEndTag):
* page/PageSerializer.cpp:
(WebCore::SerializerMarkupAccumulator::appendEndTag):
Modified Paths
Diff
Modified: releases/WebKitGTK/webkit-2.6/Source/WebCore/ChangeLog (174427 => 174428)
--- releases/WebKitGTK/webkit-2.6/Source/WebCore/ChangeLog 2014-10-08 10:37:20 UTC (rev 174427)
+++ releases/WebKitGTK/webkit-2.6/Source/WebCore/ChangeLog 2014-10-08 10:42:01 UTC (rev 174428)
@@ -1,3 +1,31 @@
+2014-09-19 Chris Dumez <[email protected]>
+
+ Minimize virtual function calls in MarkupAccumulator
+ https://bugs.webkit.org/show_bug.cgi?id=136957
+
+ Reviewed by Benjamin Poulain.
+
+ This patch minimizes the number of virtual function calls in
+ MarkupAccumulator by:
+ - De-virtualizing MarkupAccumulator::appendString(), which is never
+ overridden
+ - Having MarkupAccumulator::appendEndTag() virtual function take an
+ Element in argument instead of a Node, as it only applies to Element.
+ Also add a non-virtual overload that takes a Node in argument and
+ that does the isElementNode() check so that we don't need to explicitly
+ do the check at each call site.
+
+ No new tests, no behavior change.
+
+ * editing/MarkupAccumulator.cpp:
+ (WebCore::MarkupAccumulator::appendEndTag):
+ (WebCore::MarkupAccumulator::shouldSelfClose):
+ (WebCore::MarkupAccumulator::appendEndMarkup):
+ * editing/MarkupAccumulator.h:
+ (WebCore::MarkupAccumulator::appendEndTag):
+ * page/PageSerializer.cpp:
+ (WebCore::SerializerMarkupAccumulator::appendEndTag):
+
2014-09-19 Benjamin Poulain <[email protected]>
Add a size check for CSSSelector
Modified: releases/WebKitGTK/webkit-2.6/Source/WebCore/editing/MarkupAccumulator.cpp (174427 => 174428)
--- releases/WebKitGTK/webkit-2.6/Source/WebCore/editing/MarkupAccumulator.cpp 2014-10-08 10:37:20 UTC (rev 174427)
+++ releases/WebKitGTK/webkit-2.6/Source/WebCore/editing/MarkupAccumulator.cpp 2014-10-08 10:42:01 UTC (rev 174428)
@@ -201,9 +201,9 @@
m_nodes->append(const_cast<Node*>(&node));
}
-void MarkupAccumulator::appendEndTag(const Node& node)
+void MarkupAccumulator::appendEndTag(const Element& element)
{
- appendEndMarkup(m_markup, node);
+ appendEndMarkup(m_markup, element);
}
size_t MarkupAccumulator::totalLength(const Vector<String>& strings)
@@ -595,13 +595,13 @@
// 2. Elements w/ children never self-close because they use a separate end tag.
// 3. HTML elements which do not have a "forbidden" end tag will close with a separate end tag.
// 4. Other elements self-close.
-bool MarkupAccumulator::shouldSelfClose(const Node& node)
+bool MarkupAccumulator::shouldSelfClose(const Element& element)
{
- if (!inXMLFragmentSerialization() && node.document().isHTMLDocument())
+ if (!inXMLFragmentSerialization() && element.document().isHTMLDocument())
return false;
- if (node.hasChildNodes())
+ if (element.hasChildNodes())
return false;
- if (node.isHTMLElement() && !elementCannotHaveEndTag(node))
+ if (element.isHTMLElement() && !elementCannotHaveEndTag(element))
return false;
return true;
}
@@ -618,14 +618,14 @@
return toHTMLElement(node).ieForbidsInsertHTML();
}
-void MarkupAccumulator::appendEndMarkup(StringBuilder& result, const Node& node)
+void MarkupAccumulator::appendEndMarkup(StringBuilder& result, const Element& element)
{
- if (!node.isElementNode() || shouldSelfClose(node) || (!node.hasChildNodes() && elementCannotHaveEndTag(node)))
+ if (shouldSelfClose(element) || (!element.hasChildNodes() && elementCannotHaveEndTag(element)))
return;
result.append('<');
result.append('/');
- result.append(toElement(node).nodeNamePreservingCase());
+ result.append(element.nodeNamePreservingCase());
result.append('>');
}
Modified: releases/WebKitGTK/webkit-2.6/Source/WebCore/editing/MarkupAccumulator.h (174427 => 174428)
--- releases/WebKitGTK/webkit-2.6/Source/WebCore/editing/MarkupAccumulator.h 2014-10-08 10:37:20 UTC (rev 174427)
+++ releases/WebKitGTK/webkit-2.6/Source/WebCore/editing/MarkupAccumulator.h 2014-10-08 10:42:01 UTC (rev 174428)
@@ -26,6 +26,7 @@
#ifndef MarkupAccumulator_h
#define MarkupAccumulator_h
+#include "Element.h"
#include "markup.h"
#include <wtf/HashMap.h>
#include <wtf/text/StringBuilder.h>
@@ -72,8 +73,14 @@
void concatenateMarkup(StringBuilder&);
- virtual void appendString(const String&);
- virtual void appendEndTag(const Node&);
+ void appendString(const String&);
+ void appendEndTag(const Node& node)
+ {
+ if (node.isElementNode())
+ appendEndTag(toElement(node));
+ }
+
+ virtual void appendEndTag(const Element&);
virtual void appendCustomAttributes(StringBuilder&, const Element&, Namespaces*);
virtual void appendText(StringBuilder&, const Text&);
virtual void appendElement(StringBuilder&, const Element&, Namespaces*);
@@ -84,7 +91,7 @@
void appendCloseTag(StringBuilder&, const Element&);
void appendStartMarkup(StringBuilder&, const Node&, Namespaces*);
- void appendEndMarkup(StringBuilder&, const Node&);
+ void appendEndMarkup(StringBuilder&, const Element&);
void appendAttributeValue(StringBuilder&, const String&, bool);
void appendNodeValue(StringBuilder&, const Node&, const Range*, EntityMask);
@@ -97,7 +104,7 @@
bool shouldAddNamespaceElement(const Element&);
bool shouldAddNamespaceAttribute(const Attribute&, Namespaces&);
- bool shouldSelfClose(const Node&);
+ bool shouldSelfClose(const Element&);
bool elementCannotHaveEndTag(const Node&);
EntityMask entityMaskForText(const Text&) const;
Modified: releases/WebKitGTK/webkit-2.6/Source/WebCore/page/PageSerializer.cpp (174427 => 174428)
--- releases/WebKitGTK/webkit-2.6/Source/WebCore/page/PageSerializer.cpp 2014-10-08 10:37:20 UTC (rev 174427)
+++ releases/WebKitGTK/webkit-2.6/Source/WebCore/page/PageSerializer.cpp 2014-10-08 10:42:01 UTC (rev 174428)
@@ -106,7 +106,7 @@
virtual void appendText(StringBuilder&, const Text&) override;
virtual void appendElement(StringBuilder&, const Element&, Namespaces*) override;
virtual void appendCustomAttributes(StringBuilder&, const Element&, Namespaces*) override;
- virtual void appendEndTag(const Node&) override;
+ virtual void appendEndTag(const Element&) override;
};
SerializerMarkupAccumulator::SerializerMarkupAccumulator(PageSerializer& serializer, Document& document, Vector<Node*>* nodes)
@@ -163,10 +163,10 @@
appendAttribute(out, element, Attribute(frameOwnerURLAttributeName(frameOwner), url.string()), namespaces);
}
-void SerializerMarkupAccumulator::appendEndTag(const Node& node)
+void SerializerMarkupAccumulator::appendEndTag(const Element& element)
{
- if (node.isElementNode() && !shouldIgnoreElement(toElement(node)))
- MarkupAccumulator::appendEndTag(node);
+ if (!shouldIgnoreElement(element))
+ MarkupAccumulator::appendEndTag(element);
}
PageSerializer::Resource::Resource()