From f5771a5789836637cd72f13613915e21d086dbe4 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 2 Nov 2023 15:21:30 +0100 Subject: [PATCH] LibWeb: Check node type first in fast_is() We know that shadow roots are always document fragments, so we can check that before calling is_shadow_root() to avoid the cost of a virtual call. --- Userland/Libraries/LibWeb/DOM/ShadowRoot.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/DOM/ShadowRoot.h b/Userland/Libraries/LibWeb/DOM/ShadowRoot.h index 3eedffbd51..1456fbb9f0 100644 --- a/Userland/Libraries/LibWeb/DOM/ShadowRoot.h +++ b/Userland/Libraries/LibWeb/DOM/ShadowRoot.h @@ -48,7 +48,7 @@ private: }; template<> -inline bool Node::fast_is() const { return is_shadow_root(); } +inline bool Node::fast_is() const { return node_type() == to_underlying(NodeType::DOCUMENT_FRAGMENT_NODE) && is_shadow_root(); } template inline IterationDecision Node::for_each_shadow_including_inclusive_descendant(Callback callback)