LibWeb: Allocate dataset lazily for HTML/SVG/MathML elements

Most elements never need a dataset object, so we can avoid creating lots
of objects by making them lazy.
This commit is contained in:
Andreas Kling 2024-04-24 14:56:26 +02:00
commit 4c921e17b7
Notes: sideshowbarker 2024-07-17 06:51:10 +09:00
6 changed files with 23 additions and 11 deletions

View file

@ -23,8 +23,13 @@ void MathMLElement::initialize(JS::Realm& realm)
{
Base::initialize(realm);
WEB_SET_PROTOTYPE_FOR_INTERFACE(MathMLElement);
}
m_dataset = HTML::DOMStringMap::create(*this);
JS::NonnullGCPtr<HTML::DOMStringMap> MathMLElement::dataset()
{
if (!m_dataset)
m_dataset = HTML::DOMStringMap::create(*this);
return *m_dataset;
}
Optional<ARIA::Role> MathMLElement::default_role() const