Conversation
…ileInclusive, takeWhileInclusiveAsync Modernises 4 remaining functions that still used old-style ref cells (! / := operators) to use mutable local variables instead. This eliminates heap-allocated Ref<T> objects in these enumerators, reducing GC pressure. - singleton: state ref 0 -> mutable state = 0 - collectSeq: state ref (CollectSeqState...) -> mutable state - takeWhileInclusive: fin ref false -> mutable fin = false - takeWhileInclusiveAsync: fin ref false -> mutable fin = false All 402 tests pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dsyme
approved these changes
Apr 7, 2026
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.
Summary
Modernises 4 remaining functions that still used old-style
refcells (!/:=operators) to usemutablelocal variables instead. This eliminates heap-allocatedRef<T>objects in these enumerators, reducing GC pressure — consistent with the style improvements made across ~30 functions in v4.11.0.Changes
singletonlet state = ref 0→let mutable state = 0collectSeqlet state = ref (CollectSeqState.NotStarted inp)→let mutable state = ...takeWhileInclusivelet fin = ref false→let mutable fin = falsetakeWhileInclusiveAsynclet fin = ref false→let mutable fin = falseMotivation
In .NET,
refcells are heap-allocated objects (FSharpRef<T>). Every time the enclosing function creates a new enumerator, a new heap object is allocated just to hold the state. Usingmutablefields on the enumerator object itself (which is already heap-allocated) avoids this extra allocation and dereference overhead.Test Status
✅ All 402 tests pass (run locally with .NET 8 /
dotnet test -c Release)