Skip to content

Commit 354b9a9

Browse files
authored
Merge pull request #388 from fsprojects/repo-assist/perf-while-bang-tryTail-20260415-da41738ddc8a8560
[Repo Assist] perf: use while! in tryTail inner loop, removing redundant mutable go flag
2 parents 8fbb00b + a55407d commit 354b9a9

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

release-notes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Release notes:
88
- perf: TaskSeq.chunkBy and chunkByAsync reuse the ResizeArray buffer between chunks, reducing allocations on sequences with many chunk boundaries
99
- fixes: TaskSeq.insertAt, insertManyAt, removeAt, removeManyAt, updateAt now raise ArgumentNullException (not NullReferenceException) when given a null source; insertManyAt also validates the values argument
1010
- refactor: simplify lengthBy and lengthBeforeMax to use while! and remove the redundant mutable 'go' and initial MoveNextAsync
11+
- refactor: simplify tryTail inner loop to use while!, removing redundant mutable 'go' flag and initial MoveNextAsync
1112
- adds TaskSeq.distinctUntilChangedWith and TaskSeq.distinctUntilChangedWithAsync, #345
1213
- adds TaskSeq.withCancellation, #167
1314
- adds TaskSeq.replicateInfinite, replicateInfiniteAsync, replicateUntilNoneAsync, #345

src/FSharp.Control.TaskSeq/TaskSeqInternal.fs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -845,14 +845,8 @@ module internal TaskSeqInternal =
845845
| true ->
846846
return
847847
taskSeq {
848-
let mutable go = true
849-
let! step = e.MoveNextAsync()
850-
go <- step
851-
852-
while go do
848+
while! e.MoveNextAsync() do
853849
yield e.Current
854-
let! step = e.MoveNextAsync()
855-
go <- step
856850
}
857851
|> Some
858852
}

0 commit comments

Comments
 (0)