diff options
author | Linus Groh <mail@linusgroh.de> | 2021-04-14 22:14:54 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-14 22:37:12 +0200 |
commit | 73a92c79b8d465d65a3cf7815cd007219cb185bc (patch) | |
tree | 31748ad16e406711ab9efe48c7847218d116a5ba | |
parent | b96c205c989b8341e56e7d4b91406b201dca5bde (diff) | |
download | serenity-73a92c79b8d465d65a3cf7815cd007219cb185bc.zip |
LibJS: Use reference in MemberExpression::execute()
This was basically duplicated code.
-rw-r--r-- | Userland/Libraries/LibJS/AST.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index a99af164ae..ca7c4a444a 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -1734,16 +1734,10 @@ Value MemberExpression::execute(Interpreter& interpreter, GlobalObject& global_o { InterpreterNodeScope node_scope { interpreter, *this }; - auto object_value = m_object->execute(interpreter, global_object); - if (interpreter.exception()) - return {}; - auto* object_result = object_value.to_object(global_object); + auto reference = to_reference(interpreter, global_object); if (interpreter.exception()) return {}; - auto property_name = computed_property_name(interpreter, global_object); - if (!property_name.is_valid()) - return {}; - return object_result->get(property_name).value_or(js_undefined()); + return reference.get(global_object); } void MetaProperty::dump(int indent) const |