Skip to content

refactor: convert local tail-recursive helpers to loops#3345

Closed
bobzhang wants to merge 1 commit intomainfrom
codex/convert-local-tailcalls-into-loops
Closed

refactor: convert local tail-recursive helpers to loops#3345
bobzhang wants to merge 1 commit intomainfrom
codex/convert-local-tailcalls-into-loops

Conversation

@bobzhang
Copy link
Copy Markdown
Contributor

@bobzhang bobzhang commented Mar 25, 2026

Motivation

  • Remove small local tail-recursive helpers and convert them to explicit loop state machines to avoid recursion and make control flow explicit.
  • Keep the string/bytes regex translators aligned by applying the same pattern to both implementations.
  • Simplify List::foldi by removing an inner recursive helper and using a direct loop over the list, index and accumulator.

Description

  • Replaced the generic tail-recursive iter helper with a loop (n, init) state machine in bytes/internal/regex_engine/translate.mbt and string/internal/regex_engine/translate.mbt.
  • Replaced the local recursive go helper in List::foldi with an explicit loop (self, 0, init) in list/list.mbt.
  • These are control-flow refactors only and do not change external APIs or public interfaces.

Testing

  • Ran moon info and moon fmt successfully to update/format package interfaces.
  • Ran moon check successfully with no lint/diagnostic issues reported.
  • Ran moon test which executed 6061 tests with 6061 passed and 0 failed.

Codex Task


Open with Devin

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@coveralls
Copy link
Copy Markdown
Collaborator

Pull Request Test Coverage Report for Build 3175

Details

  • 9 of 9 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.001%) to 95.552%

Totals Coverage Status
Change from base Build 3174: -0.001%
Covered Lines: 14072
Relevant Lines: 14727

💛 - Coveralls

@bobzhang bobzhang closed this Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants