summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-04-13 19:23:30 +0200
committerAndreas Kling <kling@serenityos.org>2022-04-13 19:52:25 +0200
commit35fcb028e950c804f8f0e5295b369ee1bc541ae3 (patch)
tree66ae86cb045a13f6d6350b122053fffa36195258 /Userland/Libraries
parentb0008c0934d18c7119836f334066bc9d4817453d (diff)
downloadserenity-35fcb028e950c804f8f0e5295b369ee1bc541ae3.zip
LibJS: Tidy up Shape::ensure_property_table() a little bit
- Use a vector or references for the transition chain since null shapes are not allowed in the chain. - Use Vector::in_reverse() for iterating the chain backwards.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Shape.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Shape.cpp b/Userland/Libraries/LibJS/Runtime/Shape.cpp
index b8f820e3c9..291f1031cf 100644
--- a/Userland/Libraries/LibJS/Runtime/Shape.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Shape.cpp
@@ -162,29 +162,28 @@ void Shape::ensure_property_table() const
u32 next_offset = 0;
- Vector<Shape const*, 64> transition_chain;
+ Vector<Shape const&, 64> transition_chain;
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(*shape);
}
- transition_chain.append(this);
+ transition_chain.append(*this);
- for (ssize_t i = transition_chain.size() - 1; i >= 0; --i) {
- auto* shape = transition_chain[i];
- if (!shape->m_property_key.is_valid()) {
+ for (auto const& shape : transition_chain) {
+ if (!shape.m_property_key.is_valid()) {
// Ignore prototype transitions as they don't affect the key map.
continue;
}
- if (shape->m_transition_type == TransitionType::Put) {
- m_property_table->set(shape->m_property_key, { next_offset++, shape->m_attributes });
- } else if (shape->m_transition_type == TransitionType::Configure) {
- auto it = m_property_table->find(shape->m_property_key);
+ if (shape.m_transition_type == TransitionType::Put) {
+ m_property_table->set(shape.m_property_key, { next_offset++, shape.m_attributes });
+ } else if (shape.m_transition_type == TransitionType::Configure) {
+ auto it = m_property_table->find(shape.m_property_key);
VERIFY(it != m_property_table->end());
- it->value.attributes = shape->m_attributes;
+ it->value.attributes = shape.m_attributes;
}
}
}