refactor(builtin): share Int/Int64/Double until via a private helper#3489
Open
refactor(builtin): share Int/Int64/Double until via a private helper#3489
Conversation
9dbea3a to
ee09b2c
Compare
Extract the three near-identical loop bodies of `Int::until`, `Int64::until`, and `Double::until` into a single private generic `until_impl[T : Add + Compare + Default]` in `builtin/range.mbt`. The three public functions become one-line delegates. Public mbti is unchanged — no new traits, no new functions exported. Semantics are byte-for-byte identical, including the existing overflow handling for `(MAX_VALUE - 1).until(MAX_VALUE, inclusive=true)` on `Int` and `Int64` (covered by `builtin/iter_test.mbt:421-438`). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ee09b2c to
37f14fe
Compare
Collaborator
Coverage Report for CI Build 4044Coverage decreased (-0.005%) to 94.812%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
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.
Summary
Int::until,Int64::until, andDouble::untilinto a single private generic helperuntil_impl[T : Add + Compare + Default]inbuiltin/range.mbt.git diff origin/main builtin/pkg.generated.mbtiis empty.Why
Three copies of the same loop, with the only differences being the literal numeric type. Sharing them via a small generic helper keeps each per-type wrapper focused on its signature and lets us evolve the loop in one place.
Semantics
Byte-for-byte identical to the previous behavior, including:
inclusive=trueincludesend.(MAX_VALUE - 1).until(MAX_VALUE, inclusive=true)yields[MAX-1, MAX]and terminates without wrapping — covered by existing tests atbuiltin/iter_test.mbt:421-438for bothIntandInt64.Test plan
moon test— 6364/6364 pass.moon check— no new warnings.diff <(git show origin/main:builtin/pkg.generated.mbti) builtin/pkg.generated.mbti— empty.Diff size
2 files changed, 50 insertions(+), 63 deletions(-).
🤖 Generated with Claude Code