Skip to content

Commit 837c12b

Browse files
committed
Use STR_EMBED_P instead of testing STR_NOEMBED
1 parent 9b373fb commit 837c12b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

string.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,11 +1740,11 @@ static inline VALUE
17401740
ec_str_duplicate(struct rb_execution_context_struct *ec, VALUE klass, VALUE str)
17411741
{
17421742
VALUE dup;
1743-
if (FL_TEST(str, STR_NOEMBED)) {
1744-
dup = ec_str_alloc_heap(ec, klass);
1743+
if (STR_EMBED_P(str)) {
1744+
dup = ec_str_alloc_embed(ec, klass, RSTRING_LEN(str) + TERM_LEN(str));
17451745
}
17461746
else {
1747-
dup = ec_str_alloc_embed(ec, klass, RSTRING_LEN(str) + TERM_LEN(str));
1747+
dup = ec_str_alloc_heap(ec, klass);
17481748
}
17491749

17501750
return str_duplicate_setup(klass, str, dup);
@@ -1754,11 +1754,11 @@ static inline VALUE
17541754
str_duplicate(VALUE klass, VALUE str)
17551755
{
17561756
VALUE dup;
1757-
if (FL_TEST(str, STR_NOEMBED)) {
1758-
dup = str_alloc_heap(klass);
1757+
if (STR_EMBED_P(str)) {
1758+
dup = str_alloc_embed(klass, RSTRING_LEN(str) + TERM_LEN(str));
17591759
}
17601760
else {
1761-
dup = str_alloc_embed(klass, RSTRING_LEN(str) + TERM_LEN(str));
1761+
dup = str_alloc_heap(klass);
17621762
}
17631763

17641764
return str_duplicate_setup(klass, str, dup);
@@ -10710,11 +10710,11 @@ static VALUE
1071010710
rb_str_b(VALUE str)
1071110711
{
1071210712
VALUE str2;
10713-
if (FL_TEST(str, STR_NOEMBED)) {
10714-
str2 = str_alloc_heap(rb_cString);
10713+
if (STR_EMBED_P(str)) {
10714+
str2 = str_alloc_embed(rb_cString, RSTRING_LEN(str) + TERM_LEN(str));
1071510715
}
1071610716
else {
10717-
str2 = str_alloc_embed(rb_cString, RSTRING_LEN(str) + TERM_LEN(str));
10717+
str2 = str_alloc_heap(rb_cString);
1071810718
}
1071910719
str_replace_shared_without_enc(str2, str);
1072010720

0 commit comments

Comments
 (0)