mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:47:44 +00: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
3 changed files with 5 additions and 24 deletions
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
namespace JS {
|
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())
|
if (!value.is_object())
|
||||||
return;
|
return;
|
||||||
|
@ -65,12 +65,13 @@ static void update_function_name(Value& value, const FlyString& name, HashTable<
|
||||||
static_cast<ScriptFunction&>(function).set_name(name);
|
static_cast<ScriptFunction&>(function).set_name(name);
|
||||||
} else if (object.is_array()) {
|
} else if (object.is_array()) {
|
||||||
auto& array = static_cast<Array&>(object);
|
auto& array = static_cast<Array&>(object);
|
||||||
for (auto& entry : array.indexed_properties().values_unordered())
|
array.indexed_properties().for_each_value([&](auto& array_element_value) {
|
||||||
update_function_name(entry.value, name, visited);
|
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;
|
HashTable<const JS::Cell*> visited;
|
||||||
update_function_name(value, name, visited);
|
update_function_name(value, name, visited);
|
||||||
|
|
|
@ -387,24 +387,6 @@ Vector<u32> IndexedProperties::indices() const
|
||||||
return indices;
|
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()
|
void IndexedProperties::switch_to_generic_storage()
|
||||||
{
|
{
|
||||||
auto& storage = static_cast<SimpleIndexedPropertyStorage&>(*m_storage);
|
auto& storage = static_cast<SimpleIndexedPropertyStorage&>(*m_storage);
|
||||||
|
|
|
@ -167,8 +167,6 @@ public:
|
||||||
|
|
||||||
Vector<u32> indices() const;
|
Vector<u32> indices() const;
|
||||||
|
|
||||||
Vector<ValueAndAttributes> values_unordered() const;
|
|
||||||
|
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
void for_each_value(Callback callback)
|
void for_each_value(Callback callback)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue