mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibJS: Avoid property lookups during object initialization
When we're initializing objects, we're just adding a bunch of new properties, without transition, and without overlap (we never add the same property twice.) Take advantage of this by skipping lookups entirely (no need to see if we're overwriting an existing property) during initialization. Another nice test-js speedup :^)
This commit is contained in:
parent
7b863330dc
commit
8f535435dc
Notes:
sideshowbarker
2024-07-19 01:54:38 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/8f535435dcf
1 changed files with 9 additions and 0 deletions
|
@ -472,6 +472,15 @@ bool Object::put_own_property(Object& this_object, const StringOrSymbol& propert
|
|||
attributes.set_has_setter();
|
||||
}
|
||||
|
||||
// NOTE: We disable transitions during initialize(), this makes building common runtime objects significantly faster.
|
||||
// Transitions are primarily interesting when scripts add properties to objects.
|
||||
if (!m_transitions_enabled && !m_shape->is_unique()) {
|
||||
m_shape->add_property_without_transition(property_name, attributes);
|
||||
m_storage.resize(m_shape->property_count());
|
||||
m_storage[m_shape->property_count() - 1] = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
auto metadata = shape().lookup(property_name);
|
||||
bool new_property = !metadata.has_value();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue