1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:17:35 +00:00

LibJS: Use OrderedHashMap for the Shape property table

This allows us to get rid of property_table_ordered() which was a
heavy-handed way of iterating properties in insertion order by first
copying them to a sorted Vector.

Clients can now simply iterate property_table() directly.

3% speed-up on Kraken/ai-astar.js :^)
This commit is contained in:
Andreas Kling 2023-09-17 11:29:43 +02:00
parent 8ce9e51c97
commit e33145aa4b
7 changed files with 13 additions and 27 deletions

View file

@ -65,7 +65,7 @@ public:
Object const* prototype() const { return m_prototype; }
Optional<PropertyMetadata> lookup(StringOrSymbol const&) const;
HashMap<StringOrSymbol, PropertyMetadata> const& property_table() const;
OrderedHashMap<StringOrSymbol, PropertyMetadata> const& property_table() const;
u32 property_count() const { return m_property_count; }
struct Property {
@ -73,8 +73,6 @@ public:
PropertyMetadata value;
};
Vector<Property> property_table_ordered() const;
void set_prototype_without_transition(Object* new_prototype) { m_prototype = new_prototype; }
void remove_property_from_unique_shape(StringOrSymbol const&, size_t offset);
@ -97,7 +95,7 @@ private:
NonnullGCPtr<Realm> m_realm;
mutable OwnPtr<HashMap<StringOrSymbol, PropertyMetadata>> m_property_table;
mutable OwnPtr<OrderedHashMap<StringOrSymbol, PropertyMetadata>> m_property_table;
OwnPtr<HashMap<TransitionKey, WeakPtr<Shape>>> m_forward_transitions;
OwnPtr<HashMap<GCPtr<Object>, WeakPtr<Shape>>> m_prototype_transitions;