mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 12:49:19 +00:00
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:
parent
1560d6ad62
commit
4c921e17b7
Notes:
sideshowbarker
2024-07-17 06:51:10 +09:00
Author: https://github.com/awesomekling
Commit: 4c921e17b7
Pull-request: https://github.com/SerenityOS/serenity/pull/24100
6 changed files with 23 additions and 11 deletions
|
@ -50,8 +50,6 @@ void HTMLElement::initialize(JS::Realm& realm)
|
|||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLElement);
|
||||
|
||||
m_dataset = DOMStringMap::create(*this);
|
||||
}
|
||||
|
||||
void HTMLElement::visit_edges(Cell::Visitor& visitor)
|
||||
|
@ -60,6 +58,13 @@ void HTMLElement::visit_edges(Cell::Visitor& visitor)
|
|||
visitor.visit(m_dataset);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<DOMStringMap> HTMLElement::dataset()
|
||||
{
|
||||
if (!m_dataset)
|
||||
m_dataset = DOMStringMap::create(*this);
|
||||
return *m_dataset;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dom.html#dom-dir
|
||||
StringView HTMLElement::dir() const
|
||||
{
|
||||
|
|
|
@ -53,8 +53,7 @@ public:
|
|||
|
||||
bool cannot_navigate() const;
|
||||
|
||||
DOMStringMap* dataset() { return m_dataset.ptr(); }
|
||||
DOMStringMap const* dataset() const { return m_dataset.ptr(); }
|
||||
[[nodiscard]] JS::NonnullGCPtr<DOMStringMap> dataset();
|
||||
|
||||
void focus();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue