From d428fa0c4acfe4f70ab534d420052c193bd83281 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 9 Jun 2020 14:39:38 +0900 Subject: Replace entire `irep->pool`. Changes: - `pool format is completely replaced - supported types: `STR`, `INT32`, `INT64`, `FLOAT` - `FLOAT` may be replaced by binary representation in the future - insert `NUL` after string literals in `mrb` files - `irep->pool` no longer store values in `mrb_value` - instead it stores in `mrb_pool_value` - less allocation - `mrb_irep` can be stored in ROM --- src/string.c | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'src/string.c') diff --git a/src/string.c b/src/string.c index 97795221c..73e514f41 100644 --- a/src/string.c +++ b/src/string.c @@ -583,9 +583,6 @@ str_share(mrb_state *mrb, struct RString *orig, struct RString *s) else if (RSTR_FSHARED_P(orig)) { str_init_fshared(orig, s, orig->as.heap.aux.fshared); } - else if (mrb_frozen_p(orig) && !RSTR_POOL_P(orig)) { - str_init_fshared(orig, s, orig); - } else { if (orig->as.heap.aux.capa > orig->as.heap.len) { orig->as.heap.ptr = (char *)mrb_realloc(mrb, orig->as.heap.ptr, len+1); @@ -596,29 +593,6 @@ str_share(mrb_state *mrb, struct RString *orig, struct RString *s) } } -mrb_value -mrb_str_pool(mrb_state *mrb, const char *p, mrb_int len, mrb_bool nofree) -{ - struct RString *s = (struct RString *)mrb_malloc(mrb, sizeof(struct RString)); - - s->tt = MRB_TT_STRING; - s->c = mrb->string_class; - s->flags = 0; - - if (RSTR_EMBEDDABLE_P(len)) { - str_init_embed(s, p, len); - } - else if (nofree) { - str_init_nofree(s, p, len); - } - else { - str_init_normal(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) { -- cgit v1.2.3