diff options
author | Yves Orton <demerphq@gmail.com> | 2013-03-24 11:46:22 +0100 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2013-03-24 11:50:18 +0100 |
commit | 3a71429411c9f019441035c9f35ea66b0f169acc (patch) | |
tree | ef51a6ddae9a34d9a297520fed1d35c0d5fd5e7c /hv.c | |
parent | 7707f065b38b724eae5cbcb7ea8096ab1a2971ff (diff) | |
download | perl-3a71429411c9f019441035c9f35ea66b0f169acc.tar.gz |
improve iterator randomization
Diffstat (limited to 'hv.c')
-rw-r--r-- | hv.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -792,10 +792,7 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, * making it harder to see if there is a collision. We also * reset the iterator randomizer if there is one. */ - if (SvOOK(hv)) - HvAUX(hv)->xhv_rand= (U32)PL_hash_rand_bits; PL_hash_rand_bits += (PTRV)entry ^ hash; /* we don't bother to use ptr_hash here */ - PL_hash_rand_bits= ROTL_UV(PL_hash_rand_bits,1); if ( !*oentry || (PL_hash_rand_bits & 1) ) { HeNEXT(entry) = *oentry; *oentry = entry; @@ -803,6 +800,10 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, HeNEXT(entry) = HeNEXT(*oentry); HeNEXT(*oentry) = entry; } + PL_hash_rand_bits= ROTL_UV(PL_hash_rand_bits,1); + if (SvOOK(hv)) { + HvAUX(hv)->xhv_rand= (U32)PL_hash_rand_bits; + } if (val == &PL_sv_placeholder) HvPLACEHOLDERS(hv)++; |