mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibJS: Make use of existing property tables when reifying new ones
When reifying a shape transition chain, look for the nearest previous shape in the transition chain that has a property table already, and use that as the starting point. This achieves two things: 1. We do less work when reifying property tables that already have partial property tables earlier in the chain. 2. This enables adding properties to a shape without performing a transition. This will be useful for initializing runtime objects with way fewer allocations. See next patch. :^)
This commit is contained in:
parent
52c31bb743
commit
50ab87f651
Notes:
sideshowbarker
2024-07-19 02:01:56 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/50ab87f6517
1 changed files with 9 additions and 3 deletions
|
@ -148,16 +148,22 @@ void Shape::ensure_property_table() const
|
|||
if (m_property_table)
|
||||
return;
|
||||
m_property_table = make<HashMap<StringOrSymbol, PropertyMetadata>>();
|
||||
m_property_table->ensure_capacity(m_property_count);
|
||||
|
||||
DeferGC defer(heap());
|
||||
|
||||
u32 next_offset = 0;
|
||||
|
||||
Vector<const Shape*, 64> transition_chain;
|
||||
for (auto* shape = this; shape->m_previous; shape = shape->m_previous) {
|
||||
for (auto* shape = m_previous; shape; shape = shape->m_previous) {
|
||||
if (shape->m_property_table) {
|
||||
*m_property_table = *shape->m_property_table;
|
||||
next_offset = shape->m_property_count;
|
||||
break;
|
||||
}
|
||||
transition_chain.append(shape);
|
||||
}
|
||||
transition_chain.append(this);
|
||||
|
||||
u32 next_offset = 0;
|
||||
for (ssize_t i = transition_chain.size() - 1; i >= 0; --i) {
|
||||
auto* shape = transition_chain[i];
|
||||
if (!shape->m_property_name.is_valid()) {
|
||||
|
|
Loading…
Reference in a new issue