diff options
author | Andreas Kling <kling@serenityos.org> | 2020-12-08 15:08:49 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-12-08 17:49:02 +0100 |
commit | d2e3e038d6268d94ed326259ab1b18c8ea7a556a (patch) | |
tree | ded1ee9fe7e7a53eee450bdb63d10bd4ff94bc4c /Libraries | |
parent | 6c4b823cefba78443134e90a4fadfc02ae5c9142 (diff) | |
download | serenity-d2e3e038d6268d94ed326259ab1b18c8ea7a556a.zip |
LibJS: Use IndexedProperties::for_each_value() in update_function_name()
This allows us to get rid of IndexedProperties::values_unordered().
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibJS/AST.cpp | 9 | ||||
-rw-r--r-- | Libraries/LibJS/Runtime/IndexedProperties.cpp | 18 | ||||
-rw-r--r-- | Libraries/LibJS/Runtime/IndexedProperties.h | 2 |
3 files changed, 5 insertions, 24 deletions
diff --git a/Libraries/LibJS/AST.cpp b/Libraries/LibJS/AST.cpp index 9d0a96af6a..565d8f347e 100644 --- a/Libraries/LibJS/AST.cpp +++ b/Libraries/LibJS/AST.cpp @@ -51,7 +51,7 @@ namespace JS { -static void update_function_name(Value& value, const FlyString& name, HashTable<const JS::Cell*>& visited) +static void update_function_name(Value value, const FlyString& name, HashTable<const JS::Cell*>& visited) { if (!value.is_object()) return; @@ -65,12 +65,13 @@ static void update_function_name(Value& value, const FlyString& name, HashTable< static_cast<ScriptFunction&>(function).set_name(name); } else if (object.is_array()) { auto& array = static_cast<Array&>(object); - for (auto& entry : array.indexed_properties().values_unordered()) - update_function_name(entry.value, name, visited); + array.indexed_properties().for_each_value([&](auto& array_element_value) { + update_function_name(array_element_value, name, visited); + }); } } -static void update_function_name(Value& value, const FlyString& name) +static void update_function_name(Value value, const FlyString& name) { HashTable<const JS::Cell*> visited; update_function_name(value, name, visited); diff --git a/Libraries/LibJS/Runtime/IndexedProperties.cpp b/Libraries/LibJS/Runtime/IndexedProperties.cpp index 146296287c..7dc1b4b9a3 100644 --- a/Libraries/LibJS/Runtime/IndexedProperties.cpp +++ b/Libraries/LibJS/Runtime/IndexedProperties.cpp @@ -387,24 +387,6 @@ Vector<u32> IndexedProperties::indices() const return indices; } -Vector<ValueAndAttributes> IndexedProperties::values_unordered() const -{ - if (m_storage->is_simple_storage()) { - const auto& elements = static_cast<const SimpleIndexedPropertyStorage&>(*m_storage).elements(); - Vector<ValueAndAttributes> with_attributes; - for (auto& value : elements) - with_attributes.append({ value, default_attributes }); - return with_attributes; - } - - auto& storage = static_cast<const GenericIndexedPropertyStorage&>(*m_storage); - auto values = storage.packed_elements(); - values.ensure_capacity(values.size() + storage.sparse_elements().size()); - for (auto& entry : storage.sparse_elements()) - values.unchecked_append(entry.value); - return values; -} - void IndexedProperties::switch_to_generic_storage() { auto& storage = static_cast<SimpleIndexedPropertyStorage&>(*m_storage); diff --git a/Libraries/LibJS/Runtime/IndexedProperties.h b/Libraries/LibJS/Runtime/IndexedProperties.h index 3509e81689..984c3cef4c 100644 --- a/Libraries/LibJS/Runtime/IndexedProperties.h +++ b/Libraries/LibJS/Runtime/IndexedProperties.h @@ -167,8 +167,6 @@ public: Vector<u32> indices() const; - Vector<ValueAndAttributes> values_unordered() const; - template<typename Callback> void for_each_value(Callback callback) { |