Skip to content

perf(minifier): use atom_from_strs_array for template literal concat#20386

Draft
Boshen wants to merge 2 commits intomainfrom
perf/minifier-template-literal-arena-alloc
Draft

perf(minifier): use atom_from_strs_array for template literal concat#20386
Boshen wants to merge 2 commits intomainfrom
perf/minifier-template-literal-arena-alloc

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented Mar 14, 2026

Summary

  • Replace 4 instances of heap String concatenation with ctx.ast.atom_from_strs_array()
  • Avoids intermediate heap allocations by concatenating directly into the arena allocator
  • Affects template literal merging and expression inlining into quasis

🤖 Generated with Claude Code

…nation

Avoid intermediate heap String allocations by concatenating directly
into the arena allocator.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 14, 2026 15:57
@github-actions github-actions bot added A-minifier Area - Minifier C-performance Category - Solution not expected to change functional behavior, only performance labels Mar 14, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes constant-folding for template literals in the minifier by avoiding intermediate String allocations when concatenating template quasi raw/cooked values, instead allocating the final result directly into the arena via atom_from_strs_array.

Changes:

  • Replace to_string()/into_string() + concatenation with ctx.ast.atom_from_strs_array([...]) when merging template literal quasis in try_fold_add_op.
  • Do the same allocation optimization when inlining constant expressions into template literals in inline_template_literal.

You can also share your feedback on Copilot code review. Take the survey.

@Boshen Boshen self-assigned this Mar 14, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 14, 2026

Merging this PR will not alter performance

✅ 49 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing perf/minifier-template-literal-arena-alloc (0b4228a) with main (e62524d)

Open in CodSpeed

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Boshen Boshen marked this pull request as draft March 15, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-minifier Area - Minifier C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants