mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:17:34 +00:00
LibJS: Combine two declarative record traversals in GlobalEnvironment
In GlobalEnvironment::get_binding_value(), we can avoid an extra walk of the declarative environment record if has_binding() returns a cacheable environment coordinate.
This commit is contained in:
parent
620c495d31
commit
dbcf63e85e
1 changed files with 4 additions and 1 deletions
|
@ -116,8 +116,11 @@ ThrowCompletionOr<Value> GlobalEnvironment::get_binding_value(VM& vm, Deprecated
|
||||||
{
|
{
|
||||||
// 1. Let DclRec be envRec.[[DeclarativeRecord]].
|
// 1. Let DclRec be envRec.[[DeclarativeRecord]].
|
||||||
// 2. If ! DclRec.HasBinding(N) is true, then
|
// 2. If ! DclRec.HasBinding(N) is true, then
|
||||||
if (MUST(m_declarative_record->has_binding(name))) {
|
Optional<size_t> index;
|
||||||
|
if (MUST(m_declarative_record->has_binding(name, &index))) {
|
||||||
// a. Return ? DclRec.GetBindingValue(N, S).
|
// a. Return ? DclRec.GetBindingValue(N, S).
|
||||||
|
if (index.has_value())
|
||||||
|
return m_declarative_record->get_binding_value_direct(vm, index.value(), strict);
|
||||||
return m_declarative_record->get_binding_value(vm, name, strict);
|
return m_declarative_record->get_binding_value(vm, name, strict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue