mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 05:09:12 +00:00
LibWeb: Cache attribute names in lowercase to speed up selector matching
When matching a CSS attribute selector against an HTML element, the attribute name is case-insensitive. Before this change, that meant we had to call equals_ignoring_ascii_case() on all the attribute names. We now cache the attribute name lowercased on each Attr node, which allows us to do FlyString-to-FlyString comparison (simple pointer comparison). This brings attribute selector matching from 6% to <1% when loading our GitHub repo at https://github.com/SerenityOS/serenity
This commit is contained in:
parent
a3b4c2a30f
commit
43ef3dc0ab
Notes:
sideshowbarker
2024-07-17 02:06:40 +09:00
Author: https://github.com/awesomekling
Commit: 43ef3dc0ab
Pull-request: https://github.com/SerenityOS/serenity/pull/23602
5 changed files with 35 additions and 8 deletions
|
@ -35,6 +35,7 @@ JS::NonnullGCPtr<Attr> Attr::clone(Document& document)
|
|||
Attr::Attr(Document& document, QualifiedName qualified_name, String value, Element* owner_element)
|
||||
: Node(document, NodeType::ATTRIBUTE_NODE)
|
||||
, m_qualified_name(move(qualified_name))
|
||||
, m_lowercase_name(MUST(String(m_qualified_name.as_string()).to_lowercase()))
|
||||
, m_value(move(value))
|
||||
, m_owner_element(owner_element)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue