diff --git a/Userland/Libraries/LibJS/MarkupGenerator.cpp b/Userland/Libraries/LibJS/MarkupGenerator.cpp index 554782d434..1c2c53d0f0 100644 --- a/Userland/Libraries/LibJS/MarkupGenerator.cpp +++ b/Userland/Libraries/LibJS/MarkupGenerator.cpp @@ -123,7 +123,7 @@ ErrorOr MarkupGenerator::object_to_html(Object const& object, StringBuilde TRY(html_output.try_append(TRY(wrap_string_in_style(", "sv, StyleType::Punctuation)))); size_t index = 0; - for (auto& it : object.shape().property_table_ordered()) { + for (auto& it : object.shape().property_table()) { TRY(html_output.try_append(TRY(wrap_string_in_style(TRY(String::formatted("\"{}\"", escape_html_entities(it.key.to_display_string()))), StyleType::String)))); TRY(html_output.try_append(TRY(wrap_string_in_style(": "sv, StyleType::Punctuation)))); TRY(value_to_html(object.get_direct(it.value.offset), html_output, seen_objects)); diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index 79f3e31e4a..a61f042783 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -1027,7 +1027,7 @@ ThrowCompletionOr> Object::internal_own_property_keys() cons } // 3. For each own property key P of O such that Type(P) is String and P is not an array index, in ascending chronological order of property creation, do - for (auto& it : shape().property_table_ordered()) { + for (auto& it : shape().property_table()) { if (it.key.is_string()) { // a. Add P as the last element of keys. keys.append(it.key.to_value(vm)); @@ -1035,7 +1035,7 @@ ThrowCompletionOr> Object::internal_own_property_keys() cons } // 4. For each own property key P of O such that Type(P) is Symbol, in ascending chronological order of property creation, do - for (auto& it : shape().property_table_ordered()) { + for (auto& it : shape().property_table()) { if (it.key.is_symbol()) { // a. Add P as the last element of keys. keys.append(it.key.to_value(vm)); diff --git a/Userland/Libraries/LibJS/Runtime/Shape.cpp b/Userland/Libraries/LibJS/Runtime/Shape.cpp index 0390d963f6..1bf5c18388 100644 --- a/Userland/Libraries/LibJS/Runtime/Shape.cpp +++ b/Userland/Libraries/LibJS/Runtime/Shape.cpp @@ -136,29 +136,17 @@ Optional Shape::lookup(StringOrSymbol const& property_key) con return property; } -FLATTEN HashMap const& Shape::property_table() const +FLATTEN OrderedHashMap const& Shape::property_table() const { ensure_property_table(); return *m_property_table; } -Vector Shape::property_table_ordered() const -{ - auto vec = Vector(); - vec.resize(property_count()); - - for (auto& it : property_table()) { - vec[it.value.offset] = { it.key, it.value }; - } - - return vec; -} - void Shape::ensure_property_table() const { if (m_property_table) return; - m_property_table = make>(); + m_property_table = make>(); u32 next_offset = 0; diff --git a/Userland/Libraries/LibJS/Runtime/Shape.h b/Userland/Libraries/LibJS/Runtime/Shape.h index db11f6e496..d517ce19e5 100644 --- a/Userland/Libraries/LibJS/Runtime/Shape.h +++ b/Userland/Libraries/LibJS/Runtime/Shape.h @@ -65,7 +65,7 @@ public: Object const* prototype() const { return m_prototype; } Optional lookup(StringOrSymbol const&) const; - HashMap const& property_table() const; + OrderedHashMap const& property_table() const; u32 property_count() const { return m_property_count; } struct Property { @@ -73,8 +73,6 @@ public: PropertyMetadata value; }; - Vector 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 m_realm; - mutable OwnPtr> m_property_table; + mutable OwnPtr> m_property_table; OwnPtr>> m_forward_transitions; OwnPtr, WeakPtr>> m_prototype_transitions; diff --git a/Userland/Libraries/LibJS/Runtime/StringObject.cpp b/Userland/Libraries/LibJS/Runtime/StringObject.cpp index 2a546002b9..0e9c74fce4 100644 --- a/Userland/Libraries/LibJS/Runtime/StringObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringObject.cpp @@ -162,7 +162,7 @@ ThrowCompletionOr> StringObject::internal_own_property_keys( } // 7. For each own property key P of O such that Type(P) is String and P is not an array index, in ascending chronological order of property creation, do - for (auto& it : shape().property_table_ordered()) { + for (auto& it : shape().property_table()) { if (it.key.is_string()) { // a. Add P as the last element of keys. keys.append(it.key.to_value(vm)); @@ -170,7 +170,7 @@ ThrowCompletionOr> StringObject::internal_own_property_keys( } // 8. For each own property key P of O such that Type(P) is Symbol, in ascending chronological order of property creation, do - for (auto& it : shape().property_table_ordered()) { + for (auto& it : shape().property_table()) { if (it.key.is_symbol()) { // a. Add P as the last element of keys. keys.append(it.key.to_value(vm)); diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.h b/Userland/Libraries/LibJS/Runtime/TypedArray.h index 2abba6eef2..a721ca8388 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.h +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.h @@ -395,7 +395,7 @@ public: } // 3. For each own property key P of O such that Type(P) is String and P is not an integer index, in ascending chronological order of property creation, do - for (auto& it : shape().property_table_ordered()) { + for (auto& it : shape().property_table()) { if (it.key.is_string()) { // a. Add P as the last element of keys. keys.append(it.key.to_value(vm)); @@ -403,7 +403,7 @@ public: } // 4. For each own property key P of O such that Type(P) is Symbol, in ascending chronological order of property creation, do - for (auto& it : shape().property_table_ordered()) { + for (auto& it : shape().property_table()) { if (it.key.is_symbol()) { // a. Add P as the last element of keys. keys.append(it.key.to_value(vm)); diff --git a/Userland/Libraries/LibWeb/Bindings/LegacyPlatformObject.cpp b/Userland/Libraries/LibWeb/Bindings/LegacyPlatformObject.cpp index aacd7470bc..cd8a46a49f 100644 --- a/Userland/Libraries/LibWeb/Bindings/LegacyPlatformObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/LegacyPlatformObject.cpp @@ -400,13 +400,13 @@ JS::ThrowCompletionOr> LegacyPlatformObject::interna } // 4. For each P of O’s own property keys that is a String, in ascending chronological order of property creation, append P to keys. - for (auto& it : shape().property_table_ordered()) { + for (auto& it : shape().property_table()) { if (it.key.is_string()) keys.append(it.key.to_value(vm)); } // 5. For each P of O’s own property keys that is a Symbol, in ascending chronological order of property creation, append P to keys. - for (auto& it : shape().property_table_ordered()) { + for (auto& it : shape().property_table()) { if (it.key.is_symbol()) keys.append(it.key.to_value(vm)); }