diff options
author | Andreas Kling <kling@serenityos.org> | 2021-01-17 09:34:01 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-17 14:42:50 +0100 |
commit | fd441b954da741e992ac79acfde55cf30ccf0994 (patch) | |
tree | b9a1af28c9305684076fd6df21a25a77c21b2b61 /Userland/Libraries/LibWeb/Layout/TextNode.h | |
parent | 65fa0c2774767d0093b4fa777992e98ad1af15d5 (diff) | |
download | serenity-fd441b954da741e992ac79acfde55cf30ccf0994.zip |
LibWeb: Add fast_is<T>() for some DOM and layout node subclasses
The generic is<T>() uses dynamic_cast which is fine in the majority
of cases, but when one of them shows up in profiles, we can make it
faster by answering the is-a question manually.
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout/TextNode.h')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/TextNode.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/TextNode.h b/Userland/Libraries/LibWeb/Layout/TextNode.h index 03781a22b2..f7c6282957 100644 --- a/Userland/Libraries/LibWeb/Layout/TextNode.h +++ b/Userland/Libraries/LibWeb/Layout/TextNode.h @@ -47,6 +47,7 @@ public: virtual void split_into_lines(InlineFormattingContext&, LayoutMode) override; private: + virtual bool is_text_node() const final { return true; } void split_into_lines_by_rules(InlineFormattingContext&, LayoutMode, bool do_collapse, bool do_wrap_lines, bool do_wrap_breaks); void paint_cursor_if_needed(PaintContext&, const LineBoxFragment&) const; @@ -56,4 +57,7 @@ private: String m_text_for_rendering; }; +template<> +inline bool Node::fast_is<TextNode>() const { return is_text_node(); } + } |