Project

General

Profile

Bug #10761 » flonum-hash-fixup-r45384-v1@r49365.patch

normalperson (Eric Wong), 01/21/2015 10:20 PM

View differences:

benchmark/bm_hash_aref_flo.rb
h = {}
strs = (1..10000).to_a.map!(&:to_f)
strs.each { |s| h[s] = s }
50.times { strs.each { |s| h[s] } }
benchmark/bm_hash_aref_flo_ident.rb
h = {}.compare_by_identity
strs = (1..10000).to_a.map!(&:to_f)
strs.each { |s| h[s] = s }
50.times { strs.each { |s| h[s] } }
hash.c
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)) {
a = (st_index_t)rb_float_value(a);
}
hnum = rb_objid_hash((st_index_t)a);
}
else if (BUILTIN_TYPE(a) == T_STRING) {
st.c
* - avoid expensive modulo instructions, it is currently only
* shifts and bitmask operations.
*/
#ifdef USE_FLONUM /* RUBY */
if (FLONUM_P(n))
return (st_index_t)rb_float_value(n);
#endif
return (st_index_t)((n>>(RUBY_SPECIAL_SHIFT+3)|(n<<3)) ^ (n>>3));
}
-
(5-5/5)