mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:38:11 +00:00
LibJS: Stop using Optional<Value> in favor of Value's empty state
JS::Value already has the empty state ({} or Value() gives you one.) Use this instead of wrapping Value in Optional in some places. I've also added Value::value_or(Value) so you can easily provide a fallback value when one is not present.
This commit is contained in:
parent
5adf4901df
commit
35aea2e454
14 changed files with 60 additions and 48 deletions
|
@ -68,8 +68,8 @@ BoundFunction* Function::bind(Value bound_this_value, Vector<Value> arguments)
|
|||
if (interpreter().exception()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (length_property.has_value() && length_property.value().is_number()) {
|
||||
computed_length = max(0, length_property.value().to_i32() - static_cast<i32>(arguments.size()));
|
||||
if (length_property.is_number()) {
|
||||
computed_length = max(0, length_property.to_i32() - static_cast<i32>(arguments.size()));
|
||||
}
|
||||
|
||||
Object* constructor_prototype = nullptr;
|
||||
|
@ -77,8 +77,8 @@ BoundFunction* Function::bind(Value bound_this_value, Vector<Value> arguments)
|
|||
if (interpreter().exception()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (prototype_property.has_value() && prototype_property.value().is_object()) {
|
||||
constructor_prototype = &prototype_property.value().as_object();
|
||||
if (prototype_property.is_object()) {
|
||||
constructor_prototype = &prototype_property.as_object();
|
||||
}
|
||||
|
||||
auto all_bound_arguments = bound_arguments();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue