mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-08 20:32:56 +03:00
LibJS: Use IndexedProperties::for_each_value() in update_function_name()
This allows us to get rid of IndexedProperties::values_unordered().
This commit is contained in:
parent
6c4b823cef
commit
d2e3e038d6
Notes:
sideshowbarker
2024-07-19 00:59:25 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/d2e3e038d62
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -167,8 +167,6 @@ public:
|
||||
|
||||
Vector<u32> indices() const;
|
||||
|
||||
Vector<ValueAndAttributes> values_unordered() const;
|
||||
|
||||
template<typename Callback>
|
||||
void for_each_value(Callback callback)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user