summaryrefslogtreecommitdiff
path: root/hv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2005-12-31 16:42:08 +0000
committerNicholas Clark <nick@ccl4.org>2005-12-31 16:42:08 +0000
commit7440661e2628bf13f68b1828cf423db52f268294 (patch)
tree625d3024195755a52350792495666c2f1d3e3363 /hv.c
parent2b00a750be32d67419b465b04ecb90c2045abe25 (diff)
downloadperl-7440661e2628bf13f68b1828cf423db52f268294.tar.gz
Remove unneeded test in Perl_hv_clear_placeholders.
Rejig S_hfreeentries to a double loop, which is clearer and smaller. p4raw-id: //depot/perl@26550
Diffstat (limited to 'hv.c')
-rw-r--r--hv.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/hv.c b/hv.c
index 5ae50782af..7452b1ecb0 100644
--- a/hv.c
+++ b/hv.c
@@ -1612,9 +1612,6 @@ Perl_hv_clear_placeholders(pTHX_ HV *hv)
HE **oentry = &(HvARRAY(hv))[i];
HE *entry = *oentry;
- if (!entry)
- continue;
-
for (; entry; entry = *oentry) {
if (HeVAL(entry) == &PL_sv_placeholder) {
*oentry = HeNEXT(entry);
@@ -1677,15 +1674,14 @@ S_hfreeentries(pTHX_ HV *hv)
it's the original array. (Hopefully there will only be 1 time
round) */
HE **array = HvARRAY(hv);
- register HE *entry;
- I32 riter = 0;
- I32 max = HvMAX(hv);
+ I32 i = HvMAX(hv);
/* Because we have taken xhv_name out, the only allocated pointer
in the aux structure that might exist is the backreference array.
*/
if (SvOOK(hv)) {
+ HE *entry;
struct xpvhv_aux *iter = HvAUX(hv);
/* If there are weak references to this HV, we need to avoid
freeing them up here. In particular we need to keep the AV
@@ -1729,19 +1725,17 @@ S_hfreeentries(pTHX_ HV *hv)
HvFILL(hv) = 0;
((XPVHV*) SvANY(hv))->xhv_keys = 0;
- entry = array[0];
- for (;;) {
- if (entry) {
+
+ do {
+ /* Loop down the linked list heads */
+ HE *entry = array[i];
+
+ while (entry) {
register HE * const oentry = entry;
entry = HeNEXT(entry);
hv_free_ent(hv, oentry);
}
- if (!entry) {
- if (++riter > max)
- break;
- entry = array[riter];
- }
- }
+ } while (--i >= 0);
/* As there are no allocated pointers in the aux structure, it's now
safe to free the array we just cleaned up, if it's not the one we're