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
parent 1560d6ad62
commit 4c921e17b7
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