Skip to content

Commit fd57a33

Browse files
committed
Fix and simplify code for TaskSeq.drop
1 parent 1314a77 commit fd57a33

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/FSharp.Control.TaskSeq/TaskSeqInternal.fs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -672,14 +672,16 @@ module internal TaskSeqInternal =
672672
// skip, or stop looping if we reached the end
673673
while cont do
674674
pos <- pos + 1
675-
let! moveNext = e.MoveNextAsync()
676-
cont <- moveNext && pos <= count
675+
676+
if pos < count then
677+
let! moveNext = e.MoveNextAsync()
678+
cont <- moveNext
679+
else
680+
cont <- false
677681

678682
// return the rest
679-
while cont do
683+
while! e.MoveNextAsync() do
680684
yield e.Current
681-
let! moveNext = e.MoveNextAsync()
682-
cont <- moveNext
683685

684686
}
685687
| Take ->

0 commit comments

Comments
 (0)