summaryrefslogtreecommitdiff
path: root/hv.c
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2013-03-24 11:46:22 +0100
committerYves Orton <demerphq@gmail.com>2013-03-24 11:50:18 +0100
commit3a71429411c9f019441035c9f35ea66b0f169acc (patch)
treeef51a6ddae9a34d9a297520fed1d35c0d5fd5e7c /hv.c
parent7707f065b38b724eae5cbcb7ea8096ab1a2971ff (diff)
downloadperl-3a71429411c9f019441035c9f35ea66b0f169acc.tar.gz
improve iterator randomization
Diffstat (limited to 'hv.c')
-rw-r--r--hv.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/hv.c b/hv.c
index 0821841680..1a4558fce8 100644
--- a/hv.c
+++ b/hv.c
@@ -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)++;