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 | 9b2dd1e20d91af8dc88b300c942a8fb9c5d28c58 (patch) | |
tree | 13f8b9317108e87ceef31003b4838032025140ff /hash.c | |
parent | 3b5d60c0b1602d4aa2b1183d9842cace91d26a07 (diff) | |
download | ruby-9b2dd1e20d91af8dc88b300c942a8fb9c5d28c58.tar.gz |
* hash.c (rb_any_hash): shrinks all results in Fixnum range.
[ruby-core:15713]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -75,15 +75,16 @@ static int rb_any_hash(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: @@ -91,8 +92,10 @@ rb_any_hash(VALUE 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 const struct st_hash_type objhash = { |