ruby-changes:49358
From: nobu <ko1@a...>
Date: Mon, 25 Dec 2017 21:41:56 +0900 (JST)
Subject: [ruby-changes:49358] nobu:r61473 (trunk): hash.c: prime2
nobu 2017-12-25 21:41:52 +0900 (Mon, 25 Dec 2017) New Revision: 61473 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61473 Log: hash.c: prime2 * hash.c (prime2): turned into a uint32_t prime, as the lower 32bits, non-prime part only was used always. Modified files: trunk/hash.c Index: hash.c =================================================================== --- hash.c (revision 61472) +++ hash.c (revision 61473) @@ -224,7 +224,7 @@ rb_any_hash(VALUE a) https://github.com/ruby/ruby/blob/trunk/hash.c#L224 /* Here we two primes with random bit generation. */ static const uint64_t prime1 = ((uint64_t)0x2e0bb864 << 32) | 0xe9ea7df5; -static const uint64_t prime2 = ((uint64_t)0xcdb32970 << 32) | 0x830fcaa1; +static const uint32_t prime2 = 0x830fcab9; static inline uint64_t @@ -253,7 +253,7 @@ key64_hash(uint64_t key, uint32_t seed) https://github.com/ruby/ruby/blob/trunk/hash.c#L253 long rb_objid_hash(st_index_t index) { - return (long)key64_hash(rb_hash_start(index), (uint32_t)prime2); + return (long)key64_hash(rb_hash_start(index), prime2); } static st_index_t @@ -290,7 +290,7 @@ rb_ident_hash(st_data_t n) https://github.com/ruby/ruby/blob/trunk/hash.c#L290 } #endif - return (st_index_t)key64_hash(rb_hash_start((st_index_t)n), (uint32_t)prime2); + return (st_index_t)key64_hash(rb_hash_start((st_index_t)n), prime2); } static const struct st_hash_type identhash = { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/