8000 chore: update moon.pkg.json to include string import by bobzhang · Pull Request #2270 · moonbitlang/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore: update moon.pkg.json to include string import #2270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2025
Merged

Conversation

bobzhang
Copy link
Contributor

No description provided.

Copy link
Replacing manual string padding loop with string.repeat

Category
Performance
Code Snippet
for j in 0..<pad { tmp = "0" + tmp }
Recommendation
Using string.repeat is a better approach: tmp = "0".repeat(pad) + tmp
Reasoning
The string.repeat operation is likely optimized at the implementation level compared to repeated concatenations in a loop. This makes the code both more performant and more readable.

Using += operator for string concatenation

Category
Maintainability
Code Snippet
result = result + tmp -> result += tmp
Recommendation
The change to use += is good and should be kept
Reasoning
The += operator makes the intention clearer and is more idiomatic. It also potentially allows for more efficient string building in some implementations since it makes the mutation explicit.

Pattern matching syntax improvement

Category
Maintainability
Code Snippet
self.sign == Negative -> self.sign is Negative
Recommendation
The change to use 'is' for pattern matching is good and should be kept
Reasoning
Using 'is' for pattern matching is more idiomatic in MoonBit and makes the intent clearer that we're matching against an enum variant rather than testing equality.

@bobzhang bobzhang enabled auto-merge (squash) June 13, 2025 15:41
@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 7277

Details

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.001%) to 93.111%

Totals Coverage Status
Change from base Build 7275: 0.001%
Covered Lines: 8582
Relevant Lines: 9217

💛 - Coveralls

@bobzhang bobzhang merged commit e655b8f into main Jun 13, 2025
10 of 12 checks passed
@bobzhang bobzhang deleted the hongbo/tweak branch June 13, 2025 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0