mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibWeb: Add cached global attribute name FlyStrings
Instead of creating extremely common FlyStrings like "id" and "class"
on demand every time they are needed, we now have AttributeNames.h,
which provides Web::HTML::AttributeNames::{id,class_}
This avoids a bunch of string allocations during selector matching.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
|
||||
#include <LibWeb/CSS/SelectorEngine.h>
|
||||
#include <LibWeb/DOM/AttributeNames.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/DOM/Text.h>
|
||||
@@ -98,7 +99,7 @@ bool matches(const Selector::SimpleSelector& component, const Element& element)
|
||||
case Selector::SimpleSelector::Type::Universal:
|
||||
return true;
|
||||
case Selector::SimpleSelector::Type::Id:
|
||||
return component.value == element.attribute("id");
|
||||
return component.value == element.attribute(HTML::AttributeNames::id);
|
||||
case Selector::SimpleSelector::Type::Class:
|
||||
return element.has_class(component.value);
|
||||
case Selector::SimpleSelector::Type::TagName:
|
||||
|
||||
Reference in New Issue
Block a user