diff options
author | Linus Groh <mail@linusgroh.de> | 2023-03-01 14:52:31 +0000 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-03-01 17:55:42 +0000 |
commit | 8f1d13e73b8bae4f86e5cf2ed7c42d757a6ac0a7 (patch) | |
tree | b466f1bb18c2782c29da8683621a14ae57828fab /Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp | |
parent | e77503e49bec6917ab5104b0353f39fcaa48de41 (diff) | |
download | serenity-8f1d13e73b8bae4f86e5cf2ed7c42d757a6ac0a7.zip |
LibJS: Use a Variant instead of two Optionals for ThrowCompletionOr
Comes with the usual benefit of saving some space on the stack, as well
as making a situation where both or neither Optionals hold a value
impossible.
The various unwrapping additions are required as we can no longer
construct a ThrowCompletionOr<T> from an Optional<T> - rightfully so.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp index a585513e56..50338db90a 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> - * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -184,7 +184,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from) auto error = vm.throw_completion<TypeError>(ErrorType::ArrayMaxSize); // 2. Return ? IteratorClose(iteratorRecord, error). - return TRY(iterator_close(vm, iterator, move(error))); + return *TRY(iterator_close(vm, iterator, move(error))); } // ii. Let Pk be ! ToString(𝔽(k)). @@ -214,7 +214,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from) // 2. IfAbruptCloseIterator(mappedValue, iteratorRecord). if (mapped_value_or_error.is_error()) - return TRY(iterator_close(vm, iterator, mapped_value_or_error.release_error())); + return *TRY(iterator_close(vm, iterator, mapped_value_or_error.release_error())); mapped_value = mapped_value_or_error.release_value(); } // vii. Else, let mappedValue be nextValue. @@ -227,7 +227,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from) // IfAbruptCloseIterator(defineStatus, iteratorRecord). if (result_or_error.is_error()) - return TRY(iterator_close(vm, iterator, result_or_error.release_error())); + return *TRY(iterator_close(vm, iterator, result_or_error.release_error())); // x. Set k to k + 1. } |