Bug #10761 » flonum-hash-fixup-r45384-v1@r49365.patch
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));
|
||
}
|
||
-
|
- « Previous
- 1
- …
- 3
- 4
- 5
- Next »