summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-22 07:48:59 (GMT)
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-22 07:48:59 (GMT)
commit6d56fd067e219803e194b8b95aa00e558250cfec (patch)
tree71c35bf49f4f6b817ce34af7e8c419031c263405 /hash.c
parentc73f2d28b41a532a71b9b5000d0d59a4c6f49a91 (diff)
fix flonum hashing regression from r45384
* st.c (st_numhash): mix float value for flonum * hash.c (rb_any_hash): ditto * benchmark/bm_hash_aref_flo.rb: new benchmark * benchmark/bm_hash_ident_flo.rb: ditto [Bug #10761] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/hash.c b/hash.c
index d54ab8a..b7e2c66 100644
--- a/hash.c
+++ b/hash.c
@@ -137,7 +137,13 @@ rb_any_hash(VALUE a)
if (SPECIAL_CONST_P(a)) {
if (a == Qundef) return 0;
- if (STATIC_SYM_P(a)) a >>= (RUBY_SPECIAL_SHIFT + ID_SCOPE_SHIFT);
+ if (STATIC_SYM_P(a)) {
+ a >>= (RUBY_SPECIAL_SHIFT + ID_SCOPE_SHIFT);
+ }
+ else if (FLONUM_P(a)) {
+ /* prevent pathological behavior: [Bug #10761] */
+ a = (st_index_t)rb_float_value(a);
+ }
hnum = rb_objid_hash((st_index_t)a);
}
else if (BUILTIN_TYPE(a) == T_STRING) {