mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 01:29:17 +00:00
LibJS: Use iteration_step()
in IteratorNextUnpack instruction
Allows us to avoid code duplication for builtin iterators fast path.
This commit is contained in:
parent
bb53485dea
commit
155e60a5ff
Notes:
github-actions[bot]
2025-05-13 12:15:21 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 155e60a5ff
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4704
1 changed files with 7 additions and 13 deletions
|
@ -3172,20 +3172,14 @@ ThrowCompletionOr<void> IteratorNextUnpack::execute_impl(Bytecode::Interpreter&
|
||||||
{
|
{
|
||||||
auto& vm = interpreter.vm();
|
auto& vm = interpreter.vm();
|
||||||
auto& iterator_record = static_cast<IteratorRecord&>(interpreter.get(m_iterator_record).as_cell());
|
auto& iterator_record = static_cast<IteratorRecord&>(interpreter.get(m_iterator_record).as_cell());
|
||||||
|
auto iteration_result_or_done = TRY(iterator_step(vm, iterator_record));
|
||||||
Value value;
|
if (iteration_result_or_done.has<IterationDone>()) {
|
||||||
bool done = false;
|
interpreter.set(dst_done(), Value(true));
|
||||||
if (auto* builtin_iterator = iterator_record.iterator->as_builtin_iterator_if_next_is_not_redefined()) {
|
return {};
|
||||||
TRY(builtin_iterator->next(vm, done, value));
|
|
||||||
} else {
|
|
||||||
auto result = TRY(iterator_next(vm, iterator_record));
|
|
||||||
value = TRY(result->internal_get(vm.names.value, {}));
|
|
||||||
done = TRY(result->internal_get(vm.names.done, {})).to_boolean();
|
|
||||||
}
|
}
|
||||||
|
auto& iteration_result = iteration_result_or_done.get<IterationResult>();
|
||||||
interpreter.set(dst_done(), Value(done));
|
interpreter.set(dst_done(), TRY(iteration_result.done));
|
||||||
interpreter.set(dst_value(), value);
|
interpreter.set(dst_value(), TRY(iteration_result.value));
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue