Files
ladybird/Libraries/LibWeb/DOM/ParentNode.cpp
Andreas Kling d629cc379a LibWeb: Cache parsed selectors in Element.matches() and .closest()
Element::matches() and Element::closest() were re-parsing the selector
string on every call. The document already maintains a parsed-selector
cache for querySelector/querySelectorAll.

This patch folds that cache's lookup, parse, namespace filtering and
insertion behind a Document::parse_or_cache_selector_list(string)
and calls it from all four entry points. We also bump the cache's
limit to get more hits.

Saves 100ms of main thread time when loading the "insights" view on
our GitHub repo on my Linux machine. :^)
2026-04-19 21:32:55 +02:00

12 KiB