mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
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
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user