mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 02:29:21 +00:00
LibWeb: Add specialized fast_is for lists
Before: `is<HTMLOLListElement>` and other similar calls in this commit are resolved to `dynamic_cast`, which incurs runtime overhead for resolving the type. The Performance hit becomes apparent when rendering large lists. Callgrind analysis points to a significant performance hit from calls to `is<...>` in `Element::list_owner`. Reference: Michael Gibbs and Bjarne Stroustrup (2006) Fast dynamic casting. Softw. Pract. Exper. 2006; 36:139–156 After: Implement inline `fast_is` virtual method that immediately resolves the type. Results in noticeable performance improvement 2x-ish for lists with 20K entries. Bonus: Convert starting value for LI elements to signed integer The spec requires the start attribute and starting value to be "integer". Firefox and Chrome support a negative start attribute. FIXME: At the time of this PR, about 134 other objects resolve `is<...>` to `dynamic_cast`. It may be a good idea to coordinate similar changes to at least [some of] the ones that my have impact on performance (maybe open a new issue?).
This commit is contained in:
parent
12c9da2d3f
commit
d27b43c1ee
Notes:
github-actions[bot]
2025-06-16 11:46:35 +00:00
Author: https://github.com/manuel-za
Commit: d27b43c1ee
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4442
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/InvalidUsernameException
Reviewed-by: https://github.com/R-Goc
Reviewed-by: https://github.com/skyz1 ✅
7 changed files with 52 additions and 5 deletions
|
@ -214,6 +214,14 @@ public:
|
|||
virtual bool is_html_span_element() const { return false; }
|
||||
virtual bool is_html_frameset_element() const { return false; }
|
||||
virtual bool is_html_fieldset_element() const { return false; }
|
||||
virtual bool is_html_li_element() const { return false; }
|
||||
virtual bool is_html_menu_element() const { return false; }
|
||||
virtual bool is_html_olist_element() const { return false; }
|
||||
virtual bool is_html_ulist_element() const { return false; }
|
||||
ALWAYS_INLINE bool is_html_ol_ul_menu_element() const
|
||||
{
|
||||
return is_html_olist_element() || is_html_ulist_element() || is_html_menu_element();
|
||||
}
|
||||
virtual bool is_navigable_container() const { return false; }
|
||||
virtual bool is_lazy_loading() const { return false; }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue