[Repo Assist] perf: replace ValueOption tracking with while! in pairwise and distinctUntilChanged family#411
Draft
github-actions[bot] wants to merge 2 commits intomainfrom
Conversation
…ctUntilChanged family pairwise, distinctUntilChanged, distinctUntilChangedWith, and distinctUntilChangedWithAsync previously used a ValueOption mutable and a for-in loop over the source to track the 'previous' element. used in other optimized functions (except, exceptOfSeq, skipWhile, etc.). This avoids the per-element struct match (ValueNone vs ValueSome branch) and is structurally consistent with the rest of the library. All 5251 tests pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
24 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated pull request from Repo Assist, an AI assistant.
Summary
pairwise,distinctUntilChanged,distinctUntilChangedWith, anddistinctUntilChangedWithAsyncpreviously used aValueOptionmutable and afor current in source doloop to track the "previous" element:This PR replaces each with an explicit enumerator +
while!, consistent with the pattern already used inexcept,exceptOfSeq,skipWhile, and similar functions:Why this is better
ValueNone / ValueSomebranch. A direct mutable avoids this entirely.while!+ explicit enumerator idiom found throughout the rest of the optimised functions inTaskSeqInternal.fs.let! hasFirst = e.MoveNextAsync()check rather than inlined as a DU branch per element.What changed
src/FSharp.Control.TaskSeq/TaskSeqInternal.fs: refactoredpairwise,distinctUntilChanged,distinctUntilChangedWith,distinctUntilChangedWithAsyncrelease-notes.txt: entry underUnreleasedTest Status
dotnet build src/FSharp.Control.TaskSeq.sln -c Release— clean, 0 warnings, 0 errorsdotnet test(Release) — 5251 passed, 0 failed, 2 skippedPairwise+DistinctUntilChangedsuites — 94 passed, 0 faileddotnet fantomas src/FSharp.Control.TaskSeq/TaskSeqInternal.fs --check— no formatting changes