Commit 48ab97d
perf: direct loop in toResizeArrayAsync; simplify tryItem loop
toResizeArrayAsync previously went through the iter function with a
SimpleAction DU wrapper, causing a lambda closure allocation and
discriminated-union wrapping on every call. The new direct loop
eliminates these allocations and removes an extra layer of indirection.
This benefits toArrayAsync, toListAsync, toResizeArrayAsync, and
toIListAsync which all route through toResizeArrayAsync.
tryItem previously used a while-loop with condition idx <= index and an
inner if idx = index check on every iteration. The refactored version
advances with idx < index and captures the current element after the
loop, removing the redundant inner comparison from the hot path.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 4873e88 commit 48ab97d
File tree
2 files changed
+17
-11
lines changed- src/FSharp.Control.TaskSeq
2 files changed
+17
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
532 | 532 | | |
533 | 533 | | |
534 | 534 | | |
535 | | - | |
| 535 | + | |
536 | 536 | | |
537 | 537 | | |
538 | 538 | | |
539 | | - | |
540 | | - | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
541 | 545 | | |
542 | 546 | | |
543 | 547 | | |
| |||
915 | 919 | | |
916 | 920 | | |
917 | 921 | | |
918 | | - | |
919 | | - | |
920 | | - | |
921 | | - | |
922 | | - | |
923 | | - | |
924 | | - | |
925 | | - | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
926 | 930 | | |
927 | 931 | | |
928 | 932 | | |
| |||
0 commit comments