Move mrb_str_pool to src/string.c to use str_init family

This commit is contained in:
KOBAYASHI Shuji
2019-08-19 19:18:52 +09:00
parent 3fbd5f0029
commit 507dbf984e
2 changed files with 23 additions and 52 deletions
+23
View File
@@ -541,6 +541,29 @@ str_make_shared(mrb_state *mrb, struct RString *orig, struct RString *s)
}
}
mrb_value
mrb_str_pool(mrb_state *mrb, mrb_value str)
{
struct RString *s = (struct RString *)mrb_malloc(mrb, sizeof(struct RString));
struct RString *orig = mrb_str_ptr(str);
const char *p = RSTR_PTR(orig);
size_t len = (size_t)RSTR_LEN(orig);
s->tt = MRB_TT_STRING;
s->c = mrb->string_class;
s->flags = 0;
if (RSTR_NOFREE_P(orig)) {
str_init_nofree(s, p, len);
}
else {
str_init(mrb, s, p, len);
}
RSTR_SET_POOL_FLAG(s);
MRB_SET_FROZEN_FLAG(s);
return mrb_obj_value(s);
}
mrb_value
mrb_str_byte_subseq(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len)
{