Skip to content

Commit 6976ff3

Browse files
trflynn89awesomekling
authored andcommitted
LibJS: Mark IteratorHelper::create as infallible
This is just allocating an IteratorHelper. There is no way for this to throw an exception.
1 parent e011f8d commit 6976ff3

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

Libraries/LibJS/Runtime/IteratorHelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace JS {
1313

1414
GC_DEFINE_ALLOCATOR(IteratorHelper);
1515

16-
ThrowCompletionOr<GC::Ref<IteratorHelper>> IteratorHelper::create(Realm& realm, ReadonlySpan<GC::Ref<IteratorRecord>> underlying_iterators, GC::Ref<Closure> closure, GC::Ptr<AbruptClosure> abrupt_closure)
16+
GC::Ref<IteratorHelper> IteratorHelper::create(Realm& realm, ReadonlySpan<GC::Ref<IteratorRecord>> underlying_iterators, GC::Ref<Closure> closure, GC::Ptr<AbruptClosure> abrupt_closure)
1717
{
1818
return realm.create<IteratorHelper>(realm, realm.intrinsics().iterator_helper_prototype(), underlying_iterators, closure, abrupt_closure);
1919
}

Libraries/LibJS/Runtime/IteratorHelper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class IteratorHelper final : public GeneratorObject {
2222
using Closure = GC::Function<ThrowCompletionOr<Value>(VM&, IteratorHelper&)>;
2323
using AbruptClosure = GC::Function<ThrowCompletionOr<Value>(VM&, IteratorHelper&, Completion const&)>;
2424

25-
static ThrowCompletionOr<GC::Ref<IteratorHelper>> create(Realm&, ReadonlySpan<GC::Ref<IteratorRecord>>, GC::Ref<Closure>, GC::Ptr<AbruptClosure> = {});
25+
static GC::Ref<IteratorHelper> create(Realm&, ReadonlySpan<GC::Ref<IteratorRecord>>, GC::Ref<Closure>, GC::Ptr<AbruptClosure> = {});
2626

2727
ReadonlySpan<GC::Ref<IteratorRecord>> underlying_iterators() const { return m_underlying_iterators; }
2828

Libraries/LibJS/Runtime/IteratorPrototype.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ JS_DEFINE_NATIVE_FUNCTION(IteratorPrototype::drop)
149149

150150
// 11. Let result be CreateIteratorFromClosure(closure, "Iterator Helper", %IteratorHelperPrototype%, « [[UnderlyingIterators]] »).
151151
// 12. Set result.[[UnderlyingIterators]] to « iterated ».
152-
auto result = TRY(IteratorHelper::create(realm, { { iterated } }, closure));
152+
auto result = IteratorHelper::create(realm, { { iterated } }, closure);
153153

154154
// 11. Return result.
155155
return result;
@@ -264,7 +264,7 @@ JS_DEFINE_NATIVE_FUNCTION(IteratorPrototype::filter)
264264

265265
// 7. Let result be CreateIteratorFromClosure(closure, "Iterator Helper", %IteratorHelperPrototype%, « [[UnderlyingIterators]] »).
266266
// 8. Set result.[[UnderlyingIterators]] to « iterated ».
267-
auto result = TRY(IteratorHelper::create(realm, { { iterated } }, closure));
267+
auto result = IteratorHelper::create(realm, { { iterated } }, closure);
268268

269269
// 9. Return result.
270270
return result;
@@ -462,7 +462,7 @@ JS_DEFINE_NATIVE_FUNCTION(IteratorPrototype::flat_map)
462462

463463
// 8. Let result be CreateIteratorFromClosure(closure, "Iterator Helper", %IteratorHelperPrototype%, « [[UnderlyingIterators]] »).
464464
// 9. Set result.[[UnderlyingIterators]] to « iterated ».
465-
auto result = TRY(IteratorHelper::create(realm, { { iterated } }, closure, move(abrupt_closure)));
465+
auto result = IteratorHelper::create(realm, { { iterated } }, closure, move(abrupt_closure));
466466

467467
// 9. Return result.
468468
return result;
@@ -569,7 +569,7 @@ JS_DEFINE_NATIVE_FUNCTION(IteratorPrototype::map)
569569

570570
// 7. Let result be CreateIteratorFromClosure(closure, "Iterator Helper", %IteratorHelperPrototype%, « [[UnderlyingIterators]] »).
571571
// 8. Set result.[[UnderlyingIterators]] to « iterated ».
572-
auto result = TRY(IteratorHelper::create(realm, { { iterated } }, closure));
572+
auto result = IteratorHelper::create(realm, { { iterated } }, closure);
573573

574574
// 9. Return result.
575575
return result;
@@ -773,7 +773,7 @@ JS_DEFINE_NATIVE_FUNCTION(IteratorPrototype::take)
773773

774774
// 11. Let result be CreateIteratorFromClosure(closure, "Iterator Helper", %IteratorHelperPrototype%, « [[UnderlyingIterators]] »).
775775
// 12. Set result.[[UnderlyingIterators]] to « iterated ».
776-
auto result = TRY(IteratorHelper::create(realm, { { iterated } }, closure));
776+
auto result = IteratorHelper::create(realm, { { iterated } }, closure);
777777

778778
// 13. Return result.
779779
return result;

0 commit comments

Comments
 (0)