Skip to content
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

Improve performance of embedded string allocation #5183

Merged
merged 1 commit into from
Nov 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -1739,7 +1739,6 @@ str_duplicate_setup(VALUE klass, VALUE str, VALUE dup)
assert(str_embed_capa(dup) >= len + 1);
STR_SET_EMBED_LEN(dup, len);
MEMCPY(RSTRING(dup)->as.embed.ary, RSTRING(str)->as.embed.ary, char, len + 1);
flags &= ~RSTRING_NOEMBED;
}
else {
VALUE root = str;
Expand Down Expand Up @@ -1781,7 +1780,7 @@ static inline VALUE
ec_str_duplicate(struct rb_execution_context_struct *ec, VALUE klass, VALUE str)
{
VALUE dup;
if (FL_TEST(str, STR_NOEMBED)) {
if (!USE_RVARGC || FL_TEST(str, STR_NOEMBED)) {
dup = ec_str_alloc_heap(ec, klass);
}
else {
Expand All @@ -1795,7 +1794,7 @@ static inline VALUE
str_duplicate(VALUE klass, VALUE str)
{
VALUE dup;
if (FL_TEST(str, STR_NOEMBED)) {
if (!USE_RVARGC || FL_TEST(str, STR_NOEMBED)) {
dup = str_alloc_heap(klass);
}
else {
Expand Down