summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb/DOM/Element.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-05-26 23:07:19 +0200
committerAndreas Kling <kling@serenityos.org>2020-05-26 23:07:19 +0200
commit5069d380a8678062d9ca6f5127a8cadb545dbb3e (patch)
treea3818eef26967e165ca07ca160e6aa3208aaad03 /Libraries/LibWeb/DOM/Element.h
parent16accb71a35ad4c947cd9fefc6dc97c2a1ce3adb (diff)
downloadserenity-5069d380a8678062d9ca6f5127a8cadb545dbb3e.zip
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.
Diffstat (limited to 'Libraries/LibWeb/DOM/Element.h')
-rw-r--r--Libraries/LibWeb/DOM/Element.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/Libraries/LibWeb/DOM/Element.h b/Libraries/LibWeb/DOM/Element.h
index 70c9d83f6b..7fbf3ab394 100644
--- a/Libraries/LibWeb/DOM/Element.h
+++ b/Libraries/LibWeb/DOM/Element.h
@@ -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<>