diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-07-29 05:54:21 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-07-29 05:54:21 +0000 |
commit | 48f9012df931de3a526db7d3ce03c408a2c11ba5 (patch) | |
tree | 78fd985983a013d2004565c739bee3cf52cd2f1d /hash.c | |
parent | efc7a3a712f84e3f59f09a89a82f2c36081f0f43 (diff) | |
download | ruby-48f9012df931de3a526db7d3ce03c408a2c11ba5.tar.gz |
hash.c: fix symbol hash
* hash.c (rb_sym_hash): return same value as rb_any_hash() of
Symbol. [Bug #9381]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -129,6 +129,21 @@ rb_hash(VALUE obj) long rb_objid_hash(st_index_t index); +VALUE +rb_sym_hash(VALUE sym) +{ + st_index_t hnum; + + if (STATIC_SYM_P(sym)) { + sym >>= (RUBY_SPECIAL_SHIFT + ID_SCOPE_SHIFT); + hnum = rb_objid_hash((st_index_t)sym); + } + else { + hnum = RSYMBOL(sym)->hashval; + } + return LONG2FIX(hnum); +} + static st_index_t rb_any_hash(VALUE a) { |