diff options
author | Aaron Patterson <[email protected]> | 2021-03-16 15:30:47 -0700 |
---|---|---|
committer | Aaron Patterson <[email protected]> | 2021-03-17 10:55:37 -0700 |
commit | 8359821870d756eb75d66c5ddb5d119f6247c35d (patch) | |
tree | da96d7248f3725aadd08eed812d5460f4d6a260d /iseq.c | |
parent | ea817c60fcbdc2c4496be045f5bf028b702561ba (diff) |
Use rb_fstring for "defined" strings.
We can take advantage of fstrings to de-duplicate the defined strings.
This means we don't need to keep the list of defined strings on the VM
(or register them as mark objects)
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4279
Diffstat (limited to 'iseq.c')
-rw-r--r-- | iseq.c | 16 |
1 files changed, 1 insertions, 15 deletions
@@ -3103,24 +3103,10 @@ rb_iseq_defined_string(enum defined_type type) "expression", }; const char *estr; - VALUE *defs, str; if ((unsigned)(type - 1) >= (unsigned)numberof(expr_names)) rb_bug("unknown defined type %d", type); estr = expr_names[type - 1]; - if (!estr[0]) return 0; - defs = GET_VM()->defined_strings; - if (!defs) { - defs = ruby_xcalloc(numberof(expr_names), sizeof(VALUE)); - GET_VM()->defined_strings = defs; - } - str = defs[type-1]; - if (!str) { - str = rb_str_new_cstr(estr); - OBJ_FREEZE(str); - defs[type-1] = str; - rb_gc_register_mark_object(str); - } - return str; + return rb_fstring_cstr(estr); } /* A map from encoded_insn to insn_data: decoded insn number, its len, |