Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normative: re-use IteratorResult objects in some iterator helpers #3489

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -46804,9 +46804,9 @@ <h1>Iterator.prototype.drop ( _limit_ )</h1>
1. Let _next_ be ? IteratorStep(_iterated_).
1. If _next_ is ~done~, return ReturnCompletion(*undefined*).
1. Repeat,
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return ReturnCompletion(*undefined*).
1. Let _completion_ be Completion(Yield(_value_)).
1. Let _iteratorResult_ be ? IteratorStep(_iterated_).
1. If _iteratorResult_ is ~done~, return ReturnCompletion(*undefined*).
1. Let _completion_ be Completion(GeneratorYield(_iteratorResult_)).
1. IfAbruptCloseIterator(_completion_, _iterated_).
1. Let _result_ be CreateIteratorFromClosure(_closure_, *"Iterator Helper"*, %IteratorHelperPrototype%, « [[UnderlyingIterator]] »).
1. Set _result_.[[UnderlyingIterator]] to _iterated_.
Expand Down Expand Up @@ -46844,12 +46844,16 @@ <h1>Iterator.prototype.filter ( _predicate_ )</h1>
1. Let _closure_ be a new Abstract Closure with no parameters that captures _iterated_ and _predicate_ and performs the following steps when called:
1. Let _counter_ be 0.
1. Repeat,
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return ReturnCompletion(*undefined*).
1. Let _iteratorResult_ be ? IteratorStep(_iterated_).
1. If _iteratorResult_ is ~done~, return ReturnCompletion(*undefined*).
1. Let _value_ be Completion(IteratorValue(_iteratorResult_)).
1. If _value_ is a throw completion, then
1. Set _iterated_.[[Done]] to *true*.
1. Set _value_ to _value_.[[Value]].
1. Let _selected_ be Completion(Call(_predicate_, *undefined*, « _value_, 𝔽(_counter_) »)).
1. IfAbruptCloseIterator(_selected_, _iterated_).
1. If ToBoolean(_selected_) is *true*, then
1. Let _completion_ be Completion(Yield(_value_)).
1. Let _completion_ be Completion(GeneratorYield(_iteratorResult_)).
1. IfAbruptCloseIterator(_completion_, _iterated_).
1. Set _counter_ to _counter_ + 1.
1. Let _result_ be CreateIteratorFromClosure(_closure_, *"Iterator Helper"*, %IteratorHelperPrototype%, « [[UnderlyingIterator]] »).
Expand Down Expand Up @@ -47017,9 +47021,9 @@ <h1>Iterator.prototype.take ( _limit_ )</h1>
1. Return ? IteratorClose(_iterated_, ReturnCompletion(*undefined*)).
1. If _remaining_ ≠ +∞, then
1. Set _remaining_ to _remaining_ - 1.
1. Let _value_ be ? IteratorStepValue(_iterated_).
1. If _value_ is ~done~, return ReturnCompletion(*undefined*).
1. Let _completion_ be Completion(Yield(_value_)).
1. Let _iteratorResult_ be ? IteratorStep(_iterated_).
1. If _iteratorResult_ is ~done~, return ReturnCompletion(*undefined*).
1. Let _completion_ be Completion(GeneratorYield(_iteratorResult_)).
1. IfAbruptCloseIterator(_completion_, _iterated_).
1. Let _result_ be CreateIteratorFromClosure(_closure_, *"Iterator Helper"*, %IteratorHelperPrototype%, « [[UnderlyingIterator]] »).
1. Set _result_.[[UnderlyingIterator]] to _iterated_.
Expand Down
Loading