1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10: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:
Andreas Kling 2020-04-25 18:43:34 +02:00
parent 5adf4901df
commit 35aea2e454
14 changed files with 60 additions and 48 deletions

View file

@ -607,13 +607,13 @@ int main(int argc, char** argv)
auto property_pattern = parts[1];
auto maybe_variable = interpreter->get_variable(name);
if (!maybe_variable.has_value()) {
if (maybe_variable.is_empty()) {
maybe_variable = interpreter->global_object().get(name);
if (!maybe_variable.has_value())
if (maybe_variable.is_empty())
return {};
}
const auto& variable = maybe_variable.value();
auto variable = maybe_variable;
if (!variable.is_object())
return {};