dumping ground for random patches and texts
 help / color / mirror / Atom feed
* [PATCH] st.c (st_numhash): mix float value
@ 2015-01-22  0:49 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-01-22  0:49 UTC (permalink / raw)
  To: spew

FLONUM_P appears to generate too many false positives
in real world usage, with too many integers becoming
-2.0 or 2.0

So mix it into the original value and follow the original
shuffling path.

Revised benchmark results from hash benchmarks:

Speedup ratio: compare with the result of `2.1.5' (greater is better)
name	trunk	built
hash_aref_flo	0.007	1.583
hash_aref_flo_ident	0.004	1.146
hash_aref_miss	1.192	1.179
hash_aref_str	1.214	1.211
hash_aref_sym	1.327	1.321
hash_aref_sym_long	1.319	1.295
hash_flatten	1.386	1.364
hash_ident_num	1.181	1.188
hash_ident_obj	1.219	1.248
hash_ident_str	1.211	1.211
hash_ident_sym	1.207	1.218
hash_keys	0.951	0.951
hash_shift	1.040	1.041
hash_values	0.959	0.960
loop_whileloop2	0.992	0.993
vm2_bighash*	1.338	1.316
---
 st.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/st.c b/st.c
index 2ffa986..12f3156 100644
--- a/st.c
+++ b/st.c
@@ -1763,8 +1763,9 @@ st_numhash(st_data_t n)
      *   shifts and bitmask operations.
      */
 #ifdef USE_FLONUM /* RUBY */
-    if (FLONUM_P(n))
-	return (st_index_t)rb_float_value(n);
+    if (FLONUM_P(n)) {
+	n ^= (st_data_t)rb_float_value(n);
+    }
 #endif
 
     return (st_index_t)((n>>(RUBY_SPECIAL_SHIFT+3)|(n<<3)) ^ (n>>3));
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-01-22  0:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-22  0:49 [PATCH] st.c (st_numhash): mix float value Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).