Skip to content

Optimize template string concatenation - #629

Open
bptato wants to merge 1 commit into
bellard:masterfrom
bptato:concat
Open

bptato wants to merge 1 commit into
bellard:masterfrom
bptato:concat

Conversation

@bptato

@bptato bptato commented Nov 25, 2026

Copy link
Copy Markdown
Contributor
  • add concat, to_string opcodes & use them for template strings
  • complain on receiving overly nested template, otherwise the tag function could receive over 64k args which seems undesirable (albeit harmless, as the stack check catches it anyway)

microbench string_template shows 12ns (new) vs 17ns (old).
Maybe it could be made faster by tracking the length on the stack to avoid realloc, but I'm not convinced it's worth the complexity.

* add concat, to_string opcodes & use them for template strings
* complain on receiving overly nested template, otherwise the tag function
  could receive over 64k args which seems undesirable (albeit harmless,
  as the stack check catches it anyway)
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.

1 participant