mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:37:36 +00:00
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.
This commit is contained in:
parent
65fa0c2774
commit
fd441b954d
7 changed files with 24 additions and 17 deletions
|
@ -115,7 +115,13 @@ public:
|
|||
virtual void paint_fragment(PaintContext&, const LineBoxFragment&, PaintPhase) const { }
|
||||
virtual void after_children_paint(PaintContext&, PaintPhase) {};
|
||||
|
||||
// These are used to optimize hot is<T> variants for some classes where dynamic_cast is too slow.
|
||||
virtual bool is_box() const { return false; }
|
||||
virtual bool is_block_box() const { return false; }
|
||||
virtual bool is_text_node() const { return false; }
|
||||
|
||||
template<typename T>
|
||||
bool fast_is() const = delete;
|
||||
|
||||
bool is_floating() const;
|
||||
bool is_positioned() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue