mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 18:20:43 +09:00
LibJS: Remove unhelpful environment lookup optimization for globals
This optimization was no longer helpful after the bug fix for missing
invalidation on global delete was introduced in 331f6a9e6
, since we
now have to check bindings for presence in the global environment every
time anyway.
Since the bytecode VM now has fast GetGlobal in most cases, let's not
even worry about this and just remove the unhelpful "optimization".
In fact, removing this is actually an *optimization*, since we avoid
a redundant has_binding() check on every global variable access. :^)
This commit is contained in:
parent
6d2f9f0316
commit
640d48255b
Notes:
sideshowbarker
2024-07-17 07:08:37 +09:00
Author: https://github.com/awesomekling
Commit: 640d48255b
Pull-request: https://github.com/SerenityOS/serenity/pull/19991
5 changed files with 15 additions and 33 deletions
|
@ -67,7 +67,7 @@ ThrowCompletionOr<void> Reference::put_value(VM& vm, Value value)
|
|||
VERIFY(m_base_environment);
|
||||
|
||||
// c. Return ? base.SetMutableBinding(V.[[ReferencedName]], W, V.[[Strict]]) (see 9.1).
|
||||
if (m_environment_coordinate.has_value() && m_environment_coordinate->index != EnvironmentCoordinate::global_marker)
|
||||
if (m_environment_coordinate.has_value())
|
||||
return static_cast<DeclarativeEnvironment*>(m_base_environment)->set_mutable_binding_direct(vm, m_environment_coordinate->index, value, m_strict);
|
||||
else
|
||||
return m_base_environment->set_mutable_binding(vm, m_name.as_string(), value, m_strict);
|
||||
|
@ -137,7 +137,7 @@ ThrowCompletionOr<Value> Reference::get_value(VM& vm) const
|
|||
VERIFY(m_base_environment);
|
||||
|
||||
// c. Return ? base.GetBindingValue(V.[[ReferencedName]], V.[[Strict]]) (see 9.1).
|
||||
if (m_environment_coordinate.has_value() && m_environment_coordinate->index != EnvironmentCoordinate::global_marker)
|
||||
if (m_environment_coordinate.has_value())
|
||||
return static_cast<DeclarativeEnvironment*>(m_base_environment)->get_binding_value_direct(vm, m_environment_coordinate->index, m_strict);
|
||||
return m_base_environment->get_binding_value(vm, m_name.as_string(), m_strict);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue