mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-24 02:09:28 +00:00
LibWeb: Make HTMLCollection faster when it only cares about children
Some of the live HTMLCollection only ever contain children of their root node. When we know that's the case, we can avoid doing a full subtree traversal of all descendants and only visit children. This cuts the ECMA262 spec loading time by over 10 seconds. :^)
This commit is contained in:
@@ -42,9 +42,8 @@ JS::NonnullGCPtr<DOM::HTMLCollection> HTMLTableRowElement::cells() const
|
||||
// The cells attribute must return an HTMLCollection rooted at this tr element,
|
||||
// whose filter matches only td and th elements that are children of the tr element.
|
||||
if (!m_cells) {
|
||||
m_cells = DOM::HTMLCollection::create(const_cast<HTMLTableRowElement&>(*this), [this](Element const& element) {
|
||||
return element.parent() == this
|
||||
&& is<HTMLTableCellElement>(element);
|
||||
m_cells = DOM::HTMLCollection::create(const_cast<HTMLTableRowElement&>(*this), DOM::HTMLCollection::Scope::Children, [](Element const& element) {
|
||||
return is<HTMLTableCellElement>(element);
|
||||
}).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
return *m_cells;
|
||||
|
||||
Reference in New Issue
Block a user