Extract rb_gc_free_fstring to string.c
This allows more flexibility in how we deal with the fstring table
This commit is contained in:
parent
6f6d07272e
commit
89199a47db
Notes:
git
2025-04-18 04:04:11 +00:00
6
gc.c
6
gc.c
@ -1216,11 +1216,7 @@ rb_gc_obj_free_vm_weak_references(VALUE obj)
|
||||
switch (BUILTIN_TYPE(obj)) {
|
||||
case T_STRING:
|
||||
if (FL_TEST(obj, RSTRING_FSTR)) {
|
||||
st_data_t fstr = (st_data_t)obj;
|
||||
st_delete(rb_vm_fstring_table(), &fstr, NULL);
|
||||
RB_DEBUG_COUNTER_INC(obj_str_fstr);
|
||||
|
||||
FL_UNSET(obj, RSTRING_FSTR);
|
||||
rb_gc_free_fstring(obj);
|
||||
}
|
||||
break;
|
||||
case T_SYMBOL:
|
||||
|
@ -83,6 +83,7 @@ VALUE rb_setup_fake_str(struct RString *fake_str, const char *name, long len, rb
|
||||
RUBY_SYMBOL_EXPORT_END
|
||||
|
||||
VALUE rb_fstring_new(const char *ptr, long len);
|
||||
void rb_gc_free_fstring(VALUE obj);
|
||||
VALUE rb_obj_as_string_result(VALUE str, VALUE obj);
|
||||
VALUE rb_str_opt_plus(VALUE x, VALUE y);
|
||||
VALUE rb_str_concat_literals(size_t num, const VALUE *strary);
|
||||
|
10
string.c
10
string.c
@ -578,6 +578,16 @@ register_fstring(VALUE str, bool copy, bool force_precompute_hash)
|
||||
return args.fstr;
|
||||
}
|
||||
|
||||
void rb_gc_free_fstring(VALUE obj) {
|
||||
ASSERT_vm_locking();
|
||||
|
||||
st_data_t fstr = (st_data_t)obj;
|
||||
st_delete(rb_vm_fstring_table(), &fstr, NULL);
|
||||
RB_DEBUG_COUNTER_INC(obj_str_fstr);
|
||||
|
||||
FL_UNSET(obj, RSTRING_FSTR);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
setup_fake_str(struct RString *fake_str, const char *name, long len, int encidx)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user