Diff
Modified: trunk/Source/WebCore/ChangeLog (208710 => 208711)
--- trunk/Source/WebCore/ChangeLog 2016-11-14 22:20:59 UTC (rev 208710)
+++ trunk/Source/WebCore/ChangeLog 2016-11-14 22:54:09 UTC (rev 208711)
@@ -1,5 +1,23 @@
2016-11-14 Chris Dumez <cdu...@apple.com>
+ Avoid copying attributes vector when constructing a CustomElement in HTMLTreeBuilder
+ https://bugs.webkit.org/show_bug.cgi?id=164734
+
+ Reviewed by Ryosuke Niwa.
+
+ Avoid copying attributes vector when constructing a CustomElement in HTMLTreeBuilder.
+
+ * html/parser/HTMLConstructionSite.cpp:
+ (WebCore::HTMLConstructionSite::insertCustomElement):
+ * html/parser/HTMLConstructionSite.h:
+ * html/parser/HTMLStackItem.h:
+ (WebCore::HTMLStackItem::HTMLStackItem):
+ (WebCore::HTMLStackItem::create):
+ * html/parser/HTMLTreeBuilder.cpp:
+ (WebCore::HTMLTreeBuilder::didCreateCustomOrCallbackElement):
+
+2016-11-14 Chris Dumez <cdu...@apple.com>
+
Inline QualifiedName::toString() method
https://bugs.webkit.org/show_bug.cgi?id=164726
Modified: trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp (208710 => 208711)
--- trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp 2016-11-14 22:20:59 UTC (rev 208710)
+++ trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp 2016-11-14 22:54:09 UTC (rev 208711)
@@ -490,11 +490,11 @@
return nullptr;
}
-void HTMLConstructionSite::insertCustomElement(Ref<Element>&& element, const AtomicString& localName, Vector<Attribute>& attributes)
+void HTMLConstructionSite::insertCustomElement(Ref<Element>&& element, const AtomicString& localName, Vector<Attribute>&& attributes)
{
setAttributes(element, attributes, m_parserContentPolicy);
attachLater(currentNode(), element.copyRef());
- m_openElements.push(HTMLStackItem::create(WTFMove(element), localName, attributes));
+ m_openElements.push(HTMLStackItem::create(WTFMove(element), localName, WTFMove(attributes)));
}
void HTMLConstructionSite::insertSelfClosingHTMLElement(AtomicHTMLToken& token)
Modified: trunk/Source/WebCore/html/parser/HTMLConstructionSite.h (208710 => 208711)
--- trunk/Source/WebCore/html/parser/HTMLConstructionSite.h 2016-11-14 22:20:59 UTC (rev 208710)
+++ trunk/Source/WebCore/html/parser/HTMLConstructionSite.h 2016-11-14 22:54:09 UTC (rev 208711)
@@ -103,7 +103,7 @@
void insertCommentOnHTMLHtmlElement(AtomicHTMLToken&);
void insertHTMLElement(AtomicHTMLToken&);
JSCustomElementInterface* insertHTMLElementOrFindCustomElementInterface(AtomicHTMLToken&);
- void insertCustomElement(Ref<Element>&&, const AtomicString& localName, Vector<Attribute>&);
+ void insertCustomElement(Ref<Element>&&, const AtomicString& localName, Vector<Attribute>&&);
void insertSelfClosingHTMLElement(AtomicHTMLToken&);
void insertFormattingElement(AtomicHTMLToken&);
void insertHTMLHeadElement(AtomicHTMLToken&);
Modified: trunk/Source/WebCore/html/parser/HTMLStackItem.h (208710 => 208711)
--- trunk/Source/WebCore/html/parser/HTMLStackItem.h 2016-11-14 22:20:59 UTC (rev 208710)
+++ trunk/Source/WebCore/html/parser/HTMLStackItem.h 2016-11-14 22:54:09 UTC (rev 208711)
@@ -39,7 +39,7 @@
public:
// Normal HTMLElementStack and HTMLFormattingElementList items.
static Ref<HTMLStackItem> create(Ref<Element>&&, AtomicHTMLToken&, const AtomicString& namespaceURI = HTMLNames::xhtmlNamespaceURI);
- static Ref<HTMLStackItem> create(Ref<Element>&&, const AtomicString&, const Vector<Attribute>&);
+ static Ref<HTMLStackItem> create(Ref<Element>&&, const AtomicString&, Vector<Attribute>&&);
// Document fragment or element for parsing context.
static Ref<HTMLStackItem> create(Element&);
@@ -62,7 +62,7 @@
private:
HTMLStackItem(Ref<Element>&&, AtomicHTMLToken&, const AtomicString& namespaceURI);
- HTMLStackItem(Ref<Element>&&, const AtomicString& localName, const AtomicString& namespaceURI, const Vector<Attribute>&);
+ HTMLStackItem(Ref<Element>&&, const AtomicString& localName, const AtomicString& namespaceURI, Vector<Attribute>&&);
explicit HTMLStackItem(Element&);
explicit HTMLStackItem(DocumentFragment&);
@@ -90,19 +90,18 @@
return adoptRef(*new HTMLStackItem(WTFMove(element), token, namespaceURI));
}
-inline HTMLStackItem::HTMLStackItem(Ref<Element>&& element, const AtomicString& localName, const AtomicString& namespaceURI, const Vector<Attribute>& attributes)
+inline HTMLStackItem::HTMLStackItem(Ref<Element>&& element, const AtomicString& localName, const AtomicString& namespaceURI, Vector<Attribute>&& attributes)
: m_node(WTFMove(element))
, m_namespaceURI(namespaceURI)
, m_localName(localName)
- , m_attributes(attributes)
+ , m_attributes(WTFMove(attributes))
{
- // FIXME: We should find a way to move the attributes vector in the normal code path instead of copying it.
}
-inline Ref<HTMLStackItem> HTMLStackItem::create(Ref<Element>&& element, const AtomicString& localName, const Vector<Attribute>& attributes)
+inline Ref<HTMLStackItem> HTMLStackItem::create(Ref<Element>&& element, const AtomicString& localName, Vector<Attribute>&& attributes)
{
auto& namespaceURI = element.get().namespaceURI();
- return adoptRef(*new HTMLStackItem(WTFMove(element), localName, namespaceURI, attributes));
+ return adoptRef(*new HTMLStackItem(WTFMove(element), localName, namespaceURI, WTFMove(attributes)));
}
inline HTMLStackItem::HTMLStackItem(Element& element)
Modified: trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp (208710 => 208711)
--- trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp 2016-11-14 22:20:59 UTC (rev 208710)
+++ trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp 2016-11-14 22:54:09 UTC (rev 208711)
@@ -872,7 +872,7 @@
void HTMLTreeBuilder::didCreateCustomOrCallbackElement(Ref<Element>&& element, CustomElementConstructionData& data)
{
- m_tree.insertCustomElement(WTFMove(element), data.name, data.attributes);
+ m_tree.insertCustomElement(WTFMove(element), data.name, WTFMove(data.attributes));
}
void HTMLTreeBuilder::processTemplateStartTag(AtomicHTMLToken& token)