1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:07:45 +00:00

LibWeb: Check node type first in fast_is<ShadowRoot>()

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.
This commit is contained in:
Andreas Kling 2023-11-02 15:21:30 +01:00
parent 204c46f097
commit f5771a5789

View file

@ -48,7 +48,7 @@ private:
}; };
template<> template<>
inline bool Node::fast_is<ShadowRoot>() const { return is_shadow_root(); } inline bool Node::fast_is<ShadowRoot>() const { return node_type() == to_underlying(NodeType::DOCUMENT_FRAGMENT_NODE) && is_shadow_root(); }
template<typename Callback> template<typename Callback>
inline IterationDecision Node::for_each_shadow_including_inclusive_descendant(Callback callback) inline IterationDecision Node::for_each_shadow_including_inclusive_descendant(Callback callback)