diff options
author | Nicholas Clark <nick@ccl4.org> | 2013-02-21 17:22:23 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2013-02-26 16:00:19 +0100 |
commit | c23dc12bbfaaff3193b4bd54a44c37c5634a7f46 (patch) | |
tree | a4b8461834f0461efc7dc603ed55e0568d47a5b1 /hv.c | |
parent | 0ca1b5c32d8dd81962d7080ae0a761edace1603e (diff) | |
download | perl-c23dc12bbfaaff3193b4bd54a44c37c5634a7f46.tar.gz |
Refactor the loop logic in S_hsplit() and Perl_hv_ksplit() to converge.
Making the code as similar as possible will make it simpler to merge the two.
Diffstat (limited to 'hv.c')
-rw-r--r-- | hv.c | 22 |
1 files changed, 10 insertions, 12 deletions
@@ -1127,19 +1127,18 @@ S_hsplit(pTHX_ HV *hv) HvARRAY(hv) = (HE**) a; aep = (HE**)a; - for (i=0; i<oldsize; i++,aep++) { - HE **oentry = aep; - HE *entry = *aep; - HE **bep; + for (i=0; i<oldsize; i++) { + HE **oentry = aep + i; + HE *entry = aep[i]; if (!entry) /* non-existent */ continue; - bep = aep+oldsize; do { - if ((HeHASH(entry) & newsize) != (U32)i) { + U32 j = (HeHASH(entry) & newsize); + if (j != (U32)i) { *oentry = HeNEXT(entry); - HeNEXT(entry) = *bep; - *bep = entry; + HeNEXT(entry) = aep[j]; + aep[j] = entry; } else { oentry = &HeNEXT(entry); @@ -1200,9 +1199,9 @@ Perl_hv_ksplit(pTHX_ HV *hv, IV newmax) return; aep = (HE**)a; - for (i=0; i<oldsize; i++,aep++) { - HE **oentry = aep; - HE *entry = *aep; + for (i=0; i<oldsize; i++) { + HE **oentry = aep + i; + HE *entry = aep[i]; if (!entry) /* non-existent */ continue; @@ -1210,7 +1209,6 @@ Perl_hv_ksplit(pTHX_ HV *hv, IV newmax) I32 j = (HeHASH(entry) & newsize); if (j != i) { - j -= i; *oentry = HeNEXT(entry); HeNEXT(entry) = aep[j]; aep[j] = entry; |