From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS198093 171.25.193.0/24 X-Spam-Status: No, score=-1.5 required=3.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_XBL shortcircuit=no autolearn=no version=3.3.2 X-Original-To: spew@80x24.org Received: from 80x24.org (tor-exit0-readme.dfri.se [171.25.193.20]) by dcvr.yhbt.net (Postfix) with ESMTP id 575D21F496 for ; Thu, 22 Jan 2015 00:49:49 +0000 (UTC) From: Eric Wong To: spew@80x24.org Subject: [PATCH] st.c (st_numhash): mix float value Date: Thu, 22 Jan 2015 00:49:46 +0000 Message-Id: <1421887786-17454-1-git-send-email-e@80x24.org> X-Mailer: git-send-email 2.3.0.rc1 List-Id: 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