Skip to content

Optimized string interpolation#6334

Merged
byroot merged 2 commits intoruby:masterfrom
Shopify:str-interpolation-perf
Sep 8, 2022
Merged

Optimized string interpolation#6334
byroot merged 2 commits intoruby:masterfrom
Shopify:str-interpolation-perf

Conversation

@casperisfine
Copy link
Copy Markdown
Contributor

@casperisfine casperisfine commented Sep 8, 2022

Using rb_str_buf_append instead of rb_enc_cr_str_buf_cat shows a 1.30x improvement on the micro benchmark.

Skipping the method lookup in vm_objtostring shows and extra 1.10x, for a total of 1.40x.

@casperisfine casperisfine force-pushed the str-interpolation-perf branch 2 times, most recently from 6b62ff7 to 5222cb4 Compare September 8, 2022 11:46
We don't need it, and in string interpolation context
that's the common case.
@casperisfine casperisfine force-pushed the str-interpolation-perf branch from 5222cb4 to 2473a4c Compare September 8, 2022 12:09
@casperisfine casperisfine changed the title rb_str_concat_literals: use rb_str_buf_append Optimized string interpolation Sep 8, 2022
@byroot byroot merged commit b7fa78b into ruby:master Sep 8, 2022
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