diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-03-03 07:14:27 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-03-03 07:14:27 +0000 |
commit | 58ee1e54b0fe87a7e2e9bf2731c4383e29876cf7 (patch) | |
tree | cbebd9b62deffdfc55a20f9fbd8ebd13795e2882 /hash.c | |
parent | 9343634c6dde6787b549597b18bb2ee796e43924 (diff) |
* hash.c (rb_any_hash): shrinks all results in Fixnum range.
[ruby-core:15713]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -89,15 +89,16 @@ rb_any_hash(a) VALUE a; { VALUE hval; + int hnum; switch (TYPE(a)) { case T_FIXNUM: case T_SYMBOL: - return (int)a; + hnum = (int)a; break; case T_STRING: - return rb_str_hash(a); + hnum = rb_str_hash(a); break; default: @@ -105,8 +106,10 @@ rb_any_hash(a) if (!FIXNUM_P(hval)) { hval = rb_funcall(hval, '%', 1, INT2FIX(536870923)); } - return (int)FIX2LONG(hval); + hnum = (int)FIX2LONG(hval); } + hnum <<= 1; + return RSHIFT(hnum, 1); } static struct st_hash_type objhash = { |