mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +00:00
LibJS: Make ObjectEnvironment::set_mutable_binding() faster as well
We can combine HasProperty and Set into just Set in non-strict mode for non-with object environments.
This commit is contained in:
parent
12ceaf3790
commit
7b30df0840
1 changed files with 7 additions and 0 deletions
|
@ -92,6 +92,13 @@ ThrowCompletionOr<void> ObjectEnvironment::set_mutable_binding(VM&, FlyString co
|
|||
{
|
||||
auto& vm = this->vm();
|
||||
|
||||
// OPTIMIZATION: For non-with environments in non-strict mode, we don't need the separate HasProperty check since we only use that
|
||||
// information to throw errors in strict mode.
|
||||
// We can't do this for with environments, since it would be observable (e.g via a Proxy)
|
||||
// FIXME: I think we could combine HasProperty and Set in strict mode if Set would return a bit more failure information.
|
||||
if (!m_with_environment && !strict)
|
||||
return m_binding_object.set(name, value, Object::ShouldThrowExceptions::No);
|
||||
|
||||
// 1. Let bindingObject be envRec.[[BindingObject]].
|
||||
// 2. Let stillExists be ? HasProperty(bindingObject, N).
|
||||
auto still_exists = TRY(m_binding_object.has_property(name));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue