Skip to content
Draft
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions release-notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Release notes:

Unreleased
- refactor: simplify splitAt 'rest' taskSeq to use while!, removing redundant go2 mutable and manual MoveNextAsync pre-advance

1.1.1
- perf: use while! in groupBy, countBy, partition, except, exceptOfSeq to eliminate redundant mutable 'go' variables and initial MoveNextAsync calls
Expand Down
16 changes: 5 additions & 11 deletions src/FSharp.Control.TaskSeq/TaskSeqInternal.fs
Original file line number Diff line number Diff line change
Expand Up @@ -848,18 +848,12 @@ module internal TaskSeqInternal =
else
go <- false

// 'rest' captures 'e' from the outer task block, following the same pattern as tryTail.
// 'rest' captures 'e' from the outer task block; if the source was not exhausted,
// advance once past the last element added to 'first', then yield the remainder.
let rest = taskSeq {
let mutable go2 = go

if go2 then
let! step = e.MoveNextAsync()
go2 <- step

while go2 do
yield e.Current
let! step = e.MoveNextAsync()
go2 <- step
if go then
while! e.MoveNextAsync() do
yield e.Current
}

return first.ToArray(), rest
Expand Down
Loading