Skip to content

[Repo Assist] perf: use while! in groupBy, countBy, partition, except, exceptOfSeq#386

Open
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/perf-while-bang-groupby-countby-partition-20260413-6e4499650e6f9190
Open

[Repo Assist] perf: use while! in groupBy, countBy, partition, except, exceptOfSeq#386
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/perf-while-bang-groupby-countby-partition-20260413-6e4499650e6f9190

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 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 idiomatic while! in five functions: groupBy/groupByAsync, countBy/countByAsync, partition/partitionAsync, except, and exceptOfSeq.

The pattern being replaced (groupBy example)

Before:

let! step = e.MoveNextAsync()
let mutable go = step

while go do
    // body
    let! step = e.MoveNextAsync()
    go <- step

After:

while! e.MoveNextAsync() do
    // body

Changes

Function Change
groupBy / groupByAsync Remove go flag + initial pre-advance; use while! e.MoveNextAsync() per branch
countBy / countByAsync Same pattern
partition / partitionAsync Same pattern
except Replace go flag with let! hasFirst = e.MoveNextAsync() + if hasFirst then + while! e.MoveNextAsync()
exceptOfSeq Same as except; also uses while! excl.MoveNextAsync() to load exclusion set

Benefits

  • Removes one mutable go bool per function
  • Removes the initial pre-advance let! step = e.MoveNextAsync(); go <- step before each loop
  • Unifies style across the module — groupBy, countBy, partition, except, and exceptOfSeq now match the established while! idiom already used in sum, sumBy, average, averageBy, iter, fold, reduce, etc.
  • For except/exceptOfSeq, the first-element is also now handled before the main loop, making the code flow clearer

Scope

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

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@7ee2b60744abf71b985bead4599640f165edcd93

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@97143ac59cb3a13ef2a77581f929f06719c7402a

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>
@dsyme dsyme marked this pull request as ready for review April 13, 2026 02:12
@dsyme dsyme closed this Apr 13, 2026
@dsyme dsyme reopened this Apr 13, 2026
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.

1 participant