diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-08-15 18:10:16 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-08-15 18:10:16 +0000 |
commit | 343b2aa615b109ea6891326f45a465e90233bbeb (patch) | |
tree | 0211ed9fbf10716f6ff46c34fef46e824fc3381e /symbol.c | |
parent | 62550b1d0f07389e2806540047b8ea409ec2d707 (diff) |
merge revision(s) 51410: [Backport #11396]
* symbol.h (struct RSymbol): add hashval field
* symbol.c (dsymbol_alloc): setup hashval field once
* hash.c (rb_any_hash): return RSymbol->hashval directly
* common.mk: hash.o depends on symbol.h
Thanks to Bruno Escherl <bruno@escherl.net> for the bug report
[ruby-core:70129] [Bug #11396]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@51589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'symbol.c')
-rw-r--r-- | symbol.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -506,12 +506,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); |