Skip to content

[repo-assist] Improve: replace ref cell with mutable in mergeAll - #350

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/improve-mergeall-mutable-20260915-945f7b7c89204871
Draft

github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/improve-mergeall-mutable-20260915-945f7b7c89204871

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

AsyncSeq.mergeAll used let fin = ref n to track the number of live source sequences, with fin.Value mutated on every completion. This was the last remaining ref cell of this kind in the codebase — earlier releases (4.16.0, and the perf work on pairwise / distinctUntilChangedWithAsync) already replaced equivalent ref usages with direct mutable locals to avoid the per-call heap allocation of the Ref<'T> wrapper object.

This PR applies the same modernisation to mergeAll for consistency and to eliminate that allocation.

Changes

  • src/FSharp.Control.AsyncSeq/AsyncSeq.fs: mergeAlllet fin = ref nlet mutable fin = n; fin.Value reads/writes → direct fin reads/writes.
  • RELEASE_NOTES.md: added an entry under Unreleased.

No public API or behavioral changes.

Test Status

  • dotnet build FSharp.Control.AsyncSeq.sln -c Release — succeeded, 0 errors.
  • dotnet test tests/FSharp.Control.AsyncSeq.Tests -c Release497/497 tests passed, including the existing mergeAll tests (should work, should perform well, should be fair, should fail with AggregateException if a task fails).

🤖 This PR was created by Repo Assist, an automated AI assistant, as part of scheduled coding-improvement maintenance (Task 5). A human maintainer should review before merging.

Generated by 🌈 Repo Assist, see workflow run. Learn more.
Comment /repo-assist to run again

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@4bc8419fad05e6b032741cbfd189986700bcf71c

AsyncSeq.mergeAll used a ref<int> for its internal live-task counter,
which allocates a Ref wrapper object on the heap per call. This was
the last remaining ref cell of this kind in the codebase after prior
modernization passes (ofSeq, tryWith, tryFinally, pairwise,
distinctUntilChangedWithAsync). Replaced with a direct mutable local
for consistency and to avoid the allocation. No behavioral change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants