This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
hfreeentries zeros HvARRAY now, so skip manual
authorDavid Mitchell <davem@iabyn.com>
Tue, 3 May 2011 15:07:51 +0000 (16:07 +0100)
committerDavid Mitchell <davem@iabyn.com>
Thu, 19 May 2011 13:49:43 +0000 (14:49 +0100)
Formerly, hv_clear() and hv_undef() zeroed the contents of
HvARRAY after calling hfreeentries(), but that sub now zeroes
each elements as a by-product of its deleting algorithm.
So we can skip the Zero().

hv.c

diff --git a/hv.c b/hv.c
index 44f385b..4ac1b17 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -1544,8 +1544,6 @@ Perl_hv_clear(pTHX_ HV *hv)
     else {
        hfreeentries(hv);
        HvPLACEHOLDERS_set(hv, 0);
-       if (HvARRAY(hv))
-           Zero(HvARRAY(hv), xhv->xhv_max+1 /* HvMAX(hv)+1 */, HE*);
 
        if (SvRMAGICAL(hv))
            mg_clear(MUTABLE_SV(hv));
@@ -1745,17 +1743,10 @@ Perl_hv_undef_flags(pTHX_ HV *hv, U32 flags)
     if (SvOOK(hv)) {
       struct xpvhv_aux * const aux = HvAUX(hv);
       struct mro_meta *meta;
-      bool zeroed = FALSE;
 
       if ((name = HvENAME_get(hv))) {
-       if (PL_phase != PERL_PHASE_DESTRUCT) {
-           /* This must come at this point in case
-              mro_isa_changed_in dies. */
-           Zero(HvARRAY(hv), xhv->xhv_max+1 /* HvMAX(hv)+1 */, HE*);
-           zeroed = TRUE;
-
+       if (PL_phase != PERL_PHASE_DESTRUCT)
            mro_isa_changed_in(hv);
-       }
         if (PL_stashcache)
            (void)hv_delete(
                    PL_stashcache, name, HvENAMELEN_get(hv), G_DISCARD
@@ -1789,8 +1780,6 @@ Perl_hv_undef_flags(pTHX_ HV *hv, U32 flags)
       }
       if (!aux->xhv_name_u.xhvnameu_name && ! aux->xhv_backreferences)
        SvFLAGS(hv) &= ~SVf_OOK;
-      else if (!zeroed)
-       Zero(HvARRAY(hv), xhv->xhv_max+1 /* HvMAX(hv)+1 */, HE*);
     }
     if (!SvOOK(hv)) {
        Safefree(HvARRAY(hv));