Change dsymbol_alloc to use NEWOBJ_OF
This commit is contained in:
parent
b1964a9204
commit
4d3fc96b8b
19
symbol.c
19
symbol.c
@ -630,22 +630,23 @@ dsymbol_alloc(rb_symbols_t *symbols, const VALUE klass, const VALUE str, rb_enco
|
|||||||
{
|
{
|
||||||
ASSERT_vm_locking();
|
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;
|
long hashval;
|
||||||
|
|
||||||
rb_enc_set_index(dsym, rb_enc_to_index(enc));
|
rb_enc_set_index((VALUE)obj, rb_enc_to_index(enc));
|
||||||
OBJ_FREEZE(dsym);
|
OBJ_FREEZE((VALUE)obj);
|
||||||
RB_OBJ_WRITE(dsym, &RSYMBOL(dsym)->fstr, str);
|
RB_OBJ_WRITE((VALUE)obj, &obj->fstr, str);
|
||||||
RSYMBOL(dsym)->id = type;
|
obj->id = type;
|
||||||
|
|
||||||
/* we want hashval to be in Fixnum range [ruby-core:15713] r15672 */
|
/* we want hashval to be in Fixnum range [ruby-core:15713] r15672 */
|
||||||
hashval = (long)rb_str_hash(str);
|
hashval = (long)rb_str_hash(str);
|
||||||
RSYMBOL(dsym)->hashval = RSHIFT((long)hashval, 1);
|
obj->hashval = RSHIFT((long)hashval, 1);
|
||||||
register_sym(symbols, str, dsym);
|
register_sym(symbols, str, (VALUE)obj);
|
||||||
rb_hash_aset(symbols->dsymbol_fstr_hash, str, Qtrue);
|
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
|
static inline VALUE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user