summaryrefslogtreecommitdiff
path: root/symbol.c
diff options
context:
space:
mode:
Diffstat (limited to 'symbol.c')
-rw-r--r--symbol.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/symbol.c b/symbol.c
index 9fbe3dda74..9e2fccd689 100644
--- a/symbol.c
+++ b/symbol.c
@@ -505,12 +505,18 @@ static VALUE
dsymbol_alloc(const VALUE klass, const VALUE str, rb_encoding * const enc, const ID type)
{
const VALUE dsym = rb_newobj_of(klass, T_SYMBOL | FL_WB_PROTECTED);
+ st_index_t hashval;
rb_enc_associate(dsym, enc);
OBJ_FREEZE(dsym);
RB_OBJ_WRITE(dsym, &RSYMBOL(dsym)->fstr, str);
RSYMBOL(dsym)->id = type;
+ /* we want hashval to be in Fixnum range [ruby-core:15713] r15672 */
+ hashval = rb_str_hash(str);
+ hashval <<= 1;
+ RSYMBOL(dsym)->hashval = (st_index_t)RSHIFT(hashval, 1);
+
register_sym(str, dsym);
rb_hash_aset(global_symbols.dsymbol_fstr_hash, str, Qtrue);