From 48f9012df931de3a526db7d3ce03c408a2c11ba5 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 29 Jul 2015 05:54:21 +0000 Subject: 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 --- hash.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'hash.c') diff --git a/hash.c b/hash.c index 9ae6d9564f..e852570183 100644 --- a/hash.c +++ b/hash.c @@ -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) { -- cgit v1.2.3