Commit b6c700b
perf: optimize TaskSeq.replicate with direct object-expression implementation
Replaces the taskSeq CE (which uses a resumable state machine) and a 1..count
range IEnumerable with a minimal direct IAsyncEnumerable/IAsyncEnumerator
object expression, matching the pattern used by empty and singleton.
Benefits:
- No state machine allocation
- No range IEnumerable or IEnumerator allocation
- MoveNextAsync always completes synchronously (ValueTask<bool> hot path)
- DisposeAsync is a no-op returning ValueTask.CompletedTask
All 8 existing replicate tests pass, 4634 total tests pass.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 41f84e8 commit b6c700b
File tree
2 files changed
+17
-3
lines changed- src/FSharp.Control.TaskSeq
2 files changed
+17
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
151 | | - | |
152 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
153 | 166 | | |
154 | 167 | | |
155 | 168 | | |
| |||
0 commit comments