From c3f0f84da5e767955b0ae1eab57dca0b4401d8d5 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 2 Mar 2022 15:49:34 +0900 Subject: [PATCH] string.c: remove code duplication using `str_init_modifiable()`. --- src/string.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/string.c b/src/string.c index d49494bbb..7cc9c4ff3 100644 --- a/src/string.c +++ b/src/string.c @@ -827,12 +827,7 @@ mrb_str_to_cstr(mrb_state *mrb, mrb_value str0) const char *p = RSTRING_PTR(str0); mrb_int len = RSTRING_LEN(str0); check_null_byte(mrb, str0); - if (RSTR_EMBEDDABLE_P(len)) { - s = str_init_embed(mrb_obj_alloc_string(mrb), p, len); - } - else { - s = str_init_normal(mrb, mrb_obj_alloc_string(mrb), p, len); - } + s = str_init_modifiable(mrb, mrb_obj_alloc_string(mrb), p, len); return RSTR_PTR(s); }