summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-29 05:54:21 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-29 05:54:21 (GMT)
commit48f9012df931de3a526db7d3ce03c408a2c11ba5 (patch)
tree78fd985983a013d2004565c739bee3cf52cd2f1d /hash.c
parentefc7a3a712f84e3f59f09a89a82f2c36081f0f43 (diff)
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.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/hash.c b/hash.c
index 9ae6d95..e852570 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)
{