[Repo Assist] perf: use while! in groupBy, countBy, partition, except, exceptOfSeq#386
Open
github-actions[bot] wants to merge 1 commit intomainfrom
Conversation
Replaces the manual go-flag + initial-MoveNext pre-advance pattern with
idiomatic while! in five functions: groupBy, countBy, partition, except,
and exceptOfSeq.
The pattern being replaced (groupBy example):
let! step = e.MoveNextAsync()
let mutable go = step
while go do
// body
let! step = e.MoveNextAsync()
go <- step
After:
while! e.MoveNextAsync() do
// body
For except/exceptOfSeq the first-element check is also cleaned up:
let! hasFirst = e.MoveNextAsync()
if hasFirst then
if hashSet.Add e.Current then yield e.Current
while! e.MoveNextAsync() do ...
All changes are purely internal - no public API or behaviour change.
Verified: 5093 tests passed, 0 failures, 0 warnings, formatting OK.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
11 tasks
dsyme
approved these changes
Apr 13, 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, an AI assistant.
Summary
This PR replaces the manual
go-flag + initial-MoveNext pre-advance pattern with idiomaticwhile!in five functions:groupBy/groupByAsync,countBy/countByAsync,partition/partitionAsync,except, andexceptOfSeq.The pattern being replaced (groupBy example)
Before:
After:
Changes
groupBy/groupByAsyncgoflag + initial pre-advance; usewhile! e.MoveNextAsync()per branchcountBy/countByAsyncpartition/partitionAsyncexceptgoflag withlet! hasFirst = e.MoveNextAsync()+if hasFirst then+while! e.MoveNextAsync()exceptOfSeqexcept; also useswhile! excl.MoveNextAsync()to load exclusion setBenefits
gobool per functionlet! step = e.MoveNextAsync(); go <- stepbefore each loopgroupBy,countBy,partition,except, andexceptOfSeqnow match the establishedwhile!idiom already used insum,sumBy,average,averageBy,iter,fold,reduce, etc.except/exceptOfSeq, the first-element is also now handled before the main loop, making the code flow clearerScope
All changes are purely internal — no public API or behaviour change.
Trade-offs
None. This is a straightforward pattern replacement with identical semantics, verified by the full test suite.
Test Status
✅ Build: 0 warnings, 0 errors (Release)
✅ Fantomas: formatting check passes
✅ Tests: 5093 passed, 2 skipped, 0 failed