mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Renamed seed
as hash_salt
The role of this is a so-called "salt" but not "seed", rename to get rid of confusion with other "seed" of PRNG.
This commit is contained in:
parent
97485302db
commit
23fbee0311
Notes:
git
2020-01-09 19:05:57 +09:00
1 changed files with 8 additions and 8 deletions
16
random.c
16
random.c
|
@ -1427,33 +1427,33 @@ random_s_rand(int argc, VALUE *argv, VALUE obj)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
st_index_t hash;
|
st_index_t hash;
|
||||||
uint8_t sip[16];
|
uint8_t sip[16];
|
||||||
} seed_keys_t;
|
} hash_salt_t;
|
||||||
|
|
||||||
static union {
|
static union {
|
||||||
seed_keys_t key;
|
hash_salt_t key;
|
||||||
uint32_t u32[type_roomof(seed_keys_t, uint32_t)];
|
uint32_t u32[type_roomof(hash_salt_t, uint32_t)];
|
||||||
} seed;
|
} hash_salt;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init_seed(struct MT *mt)
|
init_seed(struct MT *mt)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < numberof(seed.u32); ++i)
|
for (i = 0; i < numberof(hash_salt.u32); ++i)
|
||||||
seed.u32[i] = genrand_int32(mt);
|
hash_salt.u32[i] = genrand_int32(mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
NO_SANITIZE("unsigned-integer-overflow", extern st_index_t rb_hash_start(st_index_t h));
|
NO_SANITIZE("unsigned-integer-overflow", extern st_index_t rb_hash_start(st_index_t h));
|
||||||
st_index_t
|
st_index_t
|
||||||
rb_hash_start(st_index_t h)
|
rb_hash_start(st_index_t h)
|
||||||
{
|
{
|
||||||
return st_hash_start(seed.key.hash + h);
|
return st_hash_start(hash_salt.key.hash + h);
|
||||||
}
|
}
|
||||||
|
|
||||||
st_index_t
|
st_index_t
|
||||||
rb_memhash(const void *ptr, long len)
|
rb_memhash(const void *ptr, long len)
|
||||||
{
|
{
|
||||||
sip_uint64_t h = sip_hash13(seed.key.sip, ptr, len);
|
sip_uint64_t h = sip_hash13(hash_salt.key.sip, ptr, len);
|
||||||
#ifdef HAVE_UINT64_T
|
#ifdef HAVE_UINT64_T
|
||||||
return (st_index_t)h;
|
return (st_index_t)h;
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in a new issue