1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Improve performance of embedded string allocation

Non-VWA embedded string allocation had a performance regression. This
commit improves performance of non-VWA embedded string allocation.
This commit is contained in:
Peter Zhu 2021-11-26 10:33:31 -05:00
parent dff8d12226
commit 7cfacbcad2
Notes: git 2021-11-27 03:28:00 +09:00

View file

@ -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;
@ -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 {
@ -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 {