Skip to content

refactor: avoid string interpolation#3381

Draft
peter-jerry-ye wants to merge 3 commits intomainfrom
zihang/avoid-string-interpolation
Draft

refactor: avoid string interpolation#3381
peter-jerry-ye wants to merge 3 commits intomainfrom
zihang/avoid-string-interpolation

Conversation

@peter-jerry-ye
Copy link
Copy Markdown
Collaborator

@peter-jerry-ye peter-jerry-ye commented Mar 30, 2026

For the abort message, we avoid using string interpolation, as they will introduce the StringBuilder APIs, and the Show APIs. We also use SourceLoc::repr directly instead of using SourceLoc::to_string. Overall this should reduce the size around abort.

This should fix the #3325 better with the following statistics:

=== Raw JS output ===
  abort: 811 bytes (4 functions)
  panic: 550 bytes (2 functions)

=== Minified (esbuild --bundle --minify) ===
  abort: 299 bytes
  panic: 136 bytes
  diff:  +163 bytes (119x overhead)

=== Gzipped ===
  abort: 241 bytes
  panic: 145 bytes
  diff:  +96 bytes

Open with Devin

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Mar 30, 2026

Pull Request Test Coverage Report for Build 3529

Details

  • 38 of 47 (80.85%) changed or added relevant lines in 7 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.05%) to 95.537%

Changes Missing Coverage Covered Lines Changed/Added Lines %
builtin/intrinsics.mbt 10 11 90.91%
builtin/utils.mbt 21 29 72.41%
Totals Coverage Status
Change from base Build 3527: -0.05%
Covered Lines: 14193
Relevant Lines: 14856

💛 - Coveralls

devin-ai-integration[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
devin-ai-integration[bot]

This comment was marked as resolved.

@peter-jerry-ye peter-jerry-ye requested a review from bobzhang March 30, 2026 11:21
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@hackwaly
Copy link
Copy Markdown
Contributor

String concat is O(n^2) compared to StringBuilder's O(n).

@peter-jerry-ye peter-jerry-ye marked this pull request as draft March 31, 2026 06:10
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.

3 participants