mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:17:44 +00:00
LibWeb: Let Element cache its list of classes
Instead of string splitting every time you call Element::has_class(), we now split the "class" attribute value when it changes, and cache the individual classes as FlyStrings in Element::m_classes. This makes has_class() significantly faster and moves the pain point of selector matching somewhere else.
This commit is contained in:
parent
16accb71a3
commit
5069d380a8
2 changed files with 15 additions and 9 deletions
|
@ -58,7 +58,7 @@ public:
|
|||
callback(attribute.name(), attribute.value());
|
||||
}
|
||||
|
||||
bool has_class(const StringView&) const;
|
||||
bool has_class(const FlyString&) const;
|
||||
|
||||
virtual void apply_presentational_hints(StyleProperties&) const { }
|
||||
virtual void parse_attribute(const FlyString& name, const String& value);
|
||||
|
@ -86,6 +86,8 @@ private:
|
|||
Vector<Attribute> m_attributes;
|
||||
|
||||
RefPtr<StyleProperties> m_resolved_style;
|
||||
|
||||
Vector<FlyString> m_classes;
|
||||
};
|
||||
|
||||
template<>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue