diff options
author | Nicholas Clark <nick@ccl4.org> | 2013-02-21 19:58:04 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2013-02-26 16:00:20 +0100 |
commit | 68303b5c043fa83afa9518dd6d3882960216ac4d (patch) | |
tree | bf0f282f5e74a1b4560d8029ecf7c61f7550c752 /hv.c | |
parent | adf6906bf1b434ce6de8a74bee3758cc5bd83b7a (diff) | |
download | perl-68303b5c043fa83afa9518dd6d3882960216ac4d.tar.gz |
Tweak S_hsplit() to return early if there are no keys to process.
This mimics the behaviour in Perl_hv_ksplit().
Also remove a vestigial comment. The code it relates to was removed in
commit 7dc8663964c66a69 in Nov 2012.
Diffstat (limited to 'hv.c')
-rw-r--r-- | hv.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -1124,8 +1124,11 @@ S_hsplit(pTHX_ HV *hv, STRLEN const oldsize, STRLEN newsize) Zero(&a[oldsize * sizeof(HE*)], (newsize-oldsize) * sizeof(HE*), char); /* zero 2nd half*/ HvMAX(hv) = --newsize; HvARRAY(hv) = (HE**) a; - aep = (HE**)a; + if (!HvTOTALKEYS(hv)) /* skip rest if no entries */ + return; + + aep = (HE**)a; for (i=0; i<oldsize; i++) { HE **oentry = aep + i; HE *entry = aep[i]; @@ -1144,9 +1147,6 @@ S_hsplit(pTHX_ HV *hv, STRLEN const oldsize, STRLEN newsize) } entry = *oentry; } while (entry); - /* I think we don't actually need to keep track of the longest length, - merely flag if anything is too long. But for the moment while - developing this code I'll track it. */ } } |