From 4d3fc96b8ba885a9f61238aa1bd51dbc056f2f5d Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Tue, 13 Feb 2024 13:44:08 -0500 Subject: Change dsymbol_alloc to use NEWOBJ_OF --- symbol.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'symbol.c') diff --git a/symbol.c b/symbol.c index bdbfbae831..dba18e4cc4 100644 --- a/symbol.c +++ b/symbol.c @@ -630,22 +630,23 @@ dsymbol_alloc(rb_symbols_t *symbols, const VALUE klass, const VALUE str, rb_enco { ASSERT_vm_locking(); - const VALUE dsym = rb_newobj_of(klass, T_SYMBOL | FL_WB_PROTECTED); + NEWOBJ_OF(obj, struct RSymbol, klass, T_SYMBOL | FL_WB_PROTECTED, sizeof(struct RSymbol), 0); + long hashval; - rb_enc_set_index(dsym, rb_enc_to_index(enc)); - OBJ_FREEZE(dsym); - RB_OBJ_WRITE(dsym, &RSYMBOL(dsym)->fstr, str); - RSYMBOL(dsym)->id = type; + rb_enc_set_index((VALUE)obj, rb_enc_to_index(enc)); + OBJ_FREEZE((VALUE)obj); + RB_OBJ_WRITE((VALUE)obj, &obj->fstr, str); + obj->id = type; /* we want hashval to be in Fixnum range [ruby-core:15713] r15672 */ hashval = (long)rb_str_hash(str); - RSYMBOL(dsym)->hashval = RSHIFT((long)hashval, 1); - register_sym(symbols, str, dsym); + obj->hashval = RSHIFT((long)hashval, 1); + register_sym(symbols, str, (VALUE)obj); rb_hash_aset(symbols->dsymbol_fstr_hash, str, Qtrue); - RUBY_DTRACE_CREATE_HOOK(SYMBOL, RSTRING_PTR(RSYMBOL(dsym)->fstr)); + RUBY_DTRACE_CREATE_HOOK(SYMBOL, RSTRING_PTR(obj->fstr)); - return dsym; + return (VALUE)obj; } static inline VALUE -- cgit v1.2.3