mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:47:34 +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:
parent
8074bdc049
commit
6108bac606
2 changed files with 4 additions and 3 deletions
|
@ -546,14 +546,15 @@ ThrowCompletionOr<Optional<PropertyDescriptor>> Object::internal_get_own_propert
|
|||
VERIFY(property_name.is_valid());
|
||||
|
||||
// 2. If O does not have an own property with key P, return undefined.
|
||||
if (!storage_has(property_name))
|
||||
auto maybe_storage_entry = storage_get(property_name);
|
||||
if (!maybe_storage_entry.has_value())
|
||||
return Optional<PropertyDescriptor> {};
|
||||
|
||||
// 3. Let D be a newly created Property Descriptor with no fields.
|
||||
PropertyDescriptor descriptor;
|
||||
|
||||
// 4. Let X be O's own property whose key is P.
|
||||
auto [value, attributes] = *storage_get(property_name);
|
||||
auto [value, attributes] = *maybe_storage_entry;
|
||||
|
||||
// 5. If X is a data property, then
|
||||
if (!value.is_accessor()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue