From 72d18038d914e7c2e383f09bae5e5bd7b06721a8 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 5 Feb 2014 14:53:48 +0000 Subject: merge revision(s) 44525,44534,44537: [Backport #9381] * hash.c (rb_objid_hash): return hash value from object ID with a salt, extract from rb_any_hash(). * object.c (rb_obj_hash): return same value as rb_any_hash(). fix r44125. [ruby-core:59638] [Bug #9381] * hash.c (rb_any_hash): should treat the return value of rb_objid_hash() as `long', because ruby assumes the object id of an object is `long'. this fixes test failures on mswin64 introduced at r44525. * hash.c (rb_objid_hash): should return `long'. brushup r44534. * object.c (rb_obj_hash): follow above change. as `long', because ruby assumes the hash value of the object id of an object is `long'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- hash.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'hash.c') diff --git a/hash.c b/hash.c index 0cbc46baf5..1c285c2b23 100644 --- a/hash.c +++ b/hash.c @@ -123,6 +123,8 @@ rb_hash(VALUE obj) return hval; } +long rb_objid_hash(st_index_t index); + static st_index_t rb_any_hash(VALUE a) { @@ -131,9 +133,7 @@ rb_any_hash(VALUE a) if (SPECIAL_CONST_P(a)) { if (a == Qundef) return 0; - hnum = rb_hash_start((st_index_t)a); - hnum = rb_hash_uint(hnum, (st_index_t)rb_any_hash); - hnum = rb_hash_end(hnum); + hnum = rb_objid_hash((st_index_t)a); } else if (BUILTIN_TYPE(a) == T_STRING) { hnum = rb_str_hash(a); @@ -146,6 +146,15 @@ rb_any_hash(VALUE a) return (st_index_t)RSHIFT(hnum, 1); } +long +rb_objid_hash(st_index_t index) +{ + st_index_t hnum = rb_hash_start(index); + hnum = rb_hash_uint(hnum, (st_index_t)rb_any_hash); + hnum = rb_hash_end(hnum); + return hnum; +} + static const struct st_hash_type objhash = { rb_any_cmp, rb_any_hash, -- cgit v1.2.3