1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:57:45 +00:00

LibJS: Only do a single property lookup in internal_get_own_property()

Instead of checking storage_has(), followed by storage_get(), we can do
storage_get() directly and avoid a redundant property lookup.

This exposed a bug in SimpleIndexedPropertyStorage::get() which would
previously succeed for array holes.
This commit is contained in:
Andreas Kling 2021-10-05 15:05:06 +02:00
parent 8074bdc049
commit 6108bac606
2 changed files with 4 additions and 3 deletions

View file

@ -26,7 +26,7 @@ bool SimpleIndexedPropertyStorage::has_index(u32 index) const
Optional<ValueAndAttributes> SimpleIndexedPropertyStorage::get(u32 index) const
{
if (index >= m_array_size)
if (!has_index(index))
return {};
return ValueAndAttributes { m_packed_elements[index], default_attributes };
}