From 58b84f953c9e91a02ec1b07f392379a1fd399e27 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 16 Sep 2021 00:52:10 +0200 Subject: [PATCH] LibWeb: Add fast_is() This was showing up as hot in profiles, as the HTML parser calls it quite a lot. --- Userland/Libraries/LibWeb/DOM/Node.h | 2 ++ Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.h | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/Userland/Libraries/LibWeb/DOM/Node.h b/Userland/Libraries/LibWeb/DOM/Node.h index 91ab9dee9d..acdd0955e6 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.h +++ b/Userland/Libraries/LibWeb/DOM/Node.h @@ -77,6 +77,8 @@ public: virtual bool is_editable() const; + virtual bool is_html_template_element() const { return false; } + ExceptionOr> pre_insert(NonnullRefPtr, RefPtr); ExceptionOr> pre_remove(NonnullRefPtr); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.h index 28b38a3b72..8382a8ef90 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.h @@ -25,9 +25,16 @@ public: virtual void cloned(Node& copy, bool clone_children) override; private: + virtual bool is_html_template_element() const final { return true; } + DOM::Document& appropriate_template_contents_owner_document(DOM::Document&); RefPtr m_content; }; } + +namespace Web::DOM { +template<> +inline bool Node::fast_is() const { return is_html_template_element(); } +}