mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:17:35 +00:00
LibJS: Use move semantics more when creating Reference objects
Turns a bunch of FlyString copies into moves.
This commit is contained in:
parent
6704961c82
commit
0d2c3f62d3
5 changed files with 18 additions and 18 deletions
|
@ -143,7 +143,7 @@ CallExpression::ThisAndCallee CallExpression::compute_this_and_callee(Interprete
|
|||
auto property_name = member_expression.computed_property_name(interpreter, global_object);
|
||||
if (!property_name.is_valid())
|
||||
return {};
|
||||
auto reference = Reference { super_base, property_name, super_base, vm.in_strict_mode() };
|
||||
auto reference = Reference { super_base, move(property_name), super_base, vm.in_strict_mode() };
|
||||
callee = reference.get_value(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
@ -805,7 +805,7 @@ Reference MemberExpression::to_reference(Interpreter& interpreter, GlobalObject&
|
|||
return Reference {};
|
||||
|
||||
auto strict = interpreter.vm().in_strict_mode();
|
||||
return Reference { object_value, property_name, {}, strict };
|
||||
return Reference { object_value, move(property_name), {}, strict };
|
||||
}
|
||||
|
||||
Value UnaryExpression::execute(Interpreter& interpreter, GlobalObject& global_object) const
|
||||
|
|
|
@ -70,15 +70,15 @@ public:
|
|||
: m_type(Type::String)
|
||||
, m_string(FlyString(string))
|
||||
{
|
||||
VERIFY(!string.is_null());
|
||||
VERIFY(!m_string.is_null());
|
||||
}
|
||||
|
||||
PropertyName(FlyString const& string, StringMayBeNumber string_may_be_number = StringMayBeNumber::Yes)
|
||||
PropertyName(FlyString string, StringMayBeNumber string_may_be_number = StringMayBeNumber::Yes)
|
||||
: m_type(Type::String)
|
||||
, m_string_may_be_number(string_may_be_number == StringMayBeNumber::Yes)
|
||||
, m_string(string)
|
||||
, m_string(move(string))
|
||||
{
|
||||
VERIFY(!string.is_null());
|
||||
VERIFY(!m_string.is_null());
|
||||
}
|
||||
|
||||
PropertyName(Symbol& symbol)
|
||||
|
|
|
@ -22,17 +22,17 @@ public:
|
|||
};
|
||||
|
||||
Reference() { }
|
||||
Reference(BaseType type, PropertyName const& name, bool strict)
|
||||
Reference(BaseType type, PropertyName name, bool strict)
|
||||
: m_base_type(type)
|
||||
, m_name(name)
|
||||
, m_name(move(name))
|
||||
, m_strict(strict)
|
||||
{
|
||||
}
|
||||
|
||||
Reference(Value base, PropertyName const& name, Value this_value, bool strict = false)
|
||||
Reference(Value base, PropertyName name, Value this_value, bool strict = false)
|
||||
: m_base_type(BaseType::Value)
|
||||
, m_base_value(base)
|
||||
, m_name(name)
|
||||
, m_name(move(name))
|
||||
, m_this_value(this_value)
|
||||
, m_strict(strict)
|
||||
{
|
||||
|
@ -44,10 +44,10 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
Reference(Environment& base, FlyString const& referenced_name, bool strict = false)
|
||||
Reference(Environment& base, FlyString referenced_name, bool strict = false)
|
||||
: m_base_type(BaseType::Environment)
|
||||
, m_base_environment(&base)
|
||||
, m_name(referenced_name)
|
||||
, m_name(move(referenced_name))
|
||||
, m_strict(strict)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -403,12 +403,12 @@ Value VM::get_variable(const FlyString& name, GlobalObject& global_object)
|
|||
}
|
||||
|
||||
// 9.1.2.1 GetIdentifierReference ( env, name, strict ), https://tc39.es/ecma262/#sec-getidentifierreference
|
||||
Reference VM::get_identifier_reference(Environment* environment, FlyString const& name, bool strict)
|
||||
Reference VM::get_identifier_reference(Environment* environment, FlyString name, bool strict)
|
||||
{
|
||||
// 1. If env is the value null, then
|
||||
if (!environment) {
|
||||
// a. Return the Reference Record { [[Base]]: unresolvable, [[ReferencedName]]: name, [[Strict]]: strict, [[ThisValue]]: empty }.
|
||||
return Reference { Reference::BaseType::Unresolvable, name, strict };
|
||||
return Reference { Reference::BaseType::Unresolvable, move(name), strict };
|
||||
}
|
||||
|
||||
// FIXME: The remainder of this function is non-conforming.
|
||||
|
@ -417,14 +417,14 @@ Reference VM::get_identifier_reference(Environment* environment, FlyString const
|
|||
for (; environment && environment->outer_environment(); environment = environment->outer_environment()) {
|
||||
auto possible_match = environment->get_from_environment(name);
|
||||
if (possible_match.has_value())
|
||||
return Reference { *environment, name, strict };
|
||||
return Reference { *environment, move(name), strict };
|
||||
}
|
||||
|
||||
if (global_object.environment().has_binding(name) || !in_strict_mode()) {
|
||||
return Reference { global_object.environment(), name, strict };
|
||||
return Reference { global_object.environment(), move(name), strict };
|
||||
}
|
||||
|
||||
return Reference { Reference::BaseType::Unresolvable, name, strict };
|
||||
return Reference { Reference::BaseType::Unresolvable, move(name), strict };
|
||||
}
|
||||
|
||||
// 9.4.2 ResolveBinding ( name [ , env ] ), https://tc39.es/ecma262/#sec-resolvebinding
|
||||
|
|
|
@ -222,7 +222,7 @@ public:
|
|||
void assign(const NonnullRefPtr<BindingPattern>& target, Value, GlobalObject&, bool first_assignment = false, Environment* specific_scope = nullptr);
|
||||
|
||||
Reference resolve_binding(FlyString const&, Environment* = nullptr);
|
||||
Reference get_identifier_reference(Environment*, FlyString const&, bool strict);
|
||||
Reference get_identifier_reference(Environment*, FlyString, bool strict);
|
||||
|
||||
template<typename T, typename... Args>
|
||||
void throw_exception(GlobalObject& global_object, Args&&... args)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue