mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:47:35 +00:00
LibWeb: Don't create mutation record node lists if nobody is interested
By deferring allocation of StaticNodeList objects until we know somebody actually wants the MutationRecord, we avoid a *lot* of allocation work. This shaves several seconds off of loading https://tc39.es/ecma262/ At least one other engine (WebKit) skips creating mutation records if nobody is interested, so even if this is observable somehow, we would at least match the behavior of a major engine.
This commit is contained in:
parent
0f2b6345c6
commit
80d6330a26
4 changed files with 22 additions and 31 deletions
|
@ -89,9 +89,7 @@ void Attr::set_value(DeprecatedString value)
|
|||
void Attr::handle_attribute_changes(Element& element, DeprecatedString const& old_value, DeprecatedString const& new_value)
|
||||
{
|
||||
// 1. Queue a mutation record of "attributes" for element with attribute’s local name, attribute’s namespace, oldValue, « », « », null, and null.
|
||||
auto added_node_list = StaticNodeList::create(realm(), {}).release_value_but_fixme_should_propagate_errors();
|
||||
auto removed_node_list = StaticNodeList::create(realm(), {}).release_value_but_fixme_should_propagate_errors();
|
||||
element.queue_mutation_record(MutationType::attributes, local_name(), namespace_uri(), old_value, added_node_list, removed_node_list, nullptr, nullptr);
|
||||
element.queue_mutation_record(MutationType::attributes, local_name(), namespace_uri(), old_value, {}, {}, nullptr, nullptr);
|
||||
|
||||
// 2. If element is custom, then enqueue a custom element callback reaction with element, callback name "attributeChangedCallback", and an argument list containing attribute’s local name, oldValue, newValue, and attribute’s namespace.
|
||||
if (element.is_custom()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue