mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
LibJS/Bytecode: Combine has_index() and get() in GetByVal and PutByVal
Since get() returns an empty Optional if the index is not present, we can combine these two into a single get() operation and save the cost of a virtual call.
This commit is contained in:
parent
55e9df4954
commit
8e04791480
1 changed files with 15 additions and 11 deletions
|
@ -123,11 +123,13 @@ inline ThrowCompletionOr<Value> get_by_value(VM& vm, Value base_value, Value pro
|
|||
|
||||
// For "non-typed arrays":
|
||||
if (!object.may_interfere_with_indexed_property_access()
|
||||
&& object_storage
|
||||
&& object_storage->has_index(index)) {
|
||||
auto value = object_storage->get(index)->value;
|
||||
if (!value.is_accessor())
|
||||
return value;
|
||||
&& object_storage) {
|
||||
auto maybe_value = object_storage->get(index);
|
||||
if (maybe_value.has_value()) {
|
||||
auto value = maybe_value->value;
|
||||
if (!value.is_accessor())
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
// For typed arrays:
|
||||
|
@ -398,12 +400,14 @@ inline ThrowCompletionOr<void> put_by_value(VM& vm, Value base, Value property_k
|
|||
// For "non-typed arrays":
|
||||
if (storage
|
||||
&& storage->is_simple_storage()
|
||||
&& !object.may_interfere_with_indexed_property_access()
|
||||
&& storage->has_index(index)) {
|
||||
auto existing_value = storage->get(index)->value;
|
||||
if (!existing_value.is_accessor()) {
|
||||
storage->put(index, value);
|
||||
return {};
|
||||
&& !object.may_interfere_with_indexed_property_access()) {
|
||||
auto maybe_value = storage->get(index);
|
||||
if (maybe_value.has_value()) {
|
||||
auto existing_value = maybe_value->value;
|
||||
if (!existing_value.is_accessor()) {
|
||||
storage->put(index, value);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue