Skip to content

Commit

Permalink
Use STR_EMBED_P instead of testing STR_NOEMBED
Browse files Browse the repository at this point in the history
  • Loading branch information
peterzhu2118 committed Aug 22, 2023
1 parent 9b373fb commit 837c12b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions string.c
Expand Up @@ -1740,11 +1740,11 @@ static inline VALUE
ec_str_duplicate(struct rb_execution_context_struct *ec, VALUE klass, VALUE str)
{
VALUE dup;
if (FL_TEST(str, STR_NOEMBED)) {
dup = ec_str_alloc_heap(ec, klass);
if (STR_EMBED_P(str)) {
dup = ec_str_alloc_embed(ec, klass, RSTRING_LEN(str) + TERM_LEN(str));
}
else {
dup = ec_str_alloc_embed(ec, klass, RSTRING_LEN(str) + TERM_LEN(str));
dup = ec_str_alloc_heap(ec, klass);
}

return str_duplicate_setup(klass, str, dup);
Expand All @@ -1754,11 +1754,11 @@ static inline VALUE
str_duplicate(VALUE klass, VALUE str)
{
VALUE dup;
if (FL_TEST(str, STR_NOEMBED)) {
dup = str_alloc_heap(klass);
if (STR_EMBED_P(str)) {
dup = str_alloc_embed(klass, RSTRING_LEN(str) + TERM_LEN(str));
}
else {
dup = str_alloc_embed(klass, RSTRING_LEN(str) + TERM_LEN(str));
dup = str_alloc_heap(klass);
}

return str_duplicate_setup(klass, str, dup);
Expand Down Expand Up @@ -10710,11 +10710,11 @@ static VALUE
rb_str_b(VALUE str)
{
VALUE str2;
if (FL_TEST(str, STR_NOEMBED)) {
str2 = str_alloc_heap(rb_cString);
if (STR_EMBED_P(str)) {
str2 = str_alloc_embed(rb_cString, RSTRING_LEN(str) + TERM_LEN(str));
}
else {
str2 = str_alloc_embed(rb_cString, RSTRING_LEN(str) + TERM_LEN(str));
str2 = str_alloc_heap(rb_cString);
}
str_replace_shared_without_enc(str2, str);

Expand Down

0 comments on commit 837c12b

Please sign in to comment.