From: Nicholas Clark Date: Wed, 1 Jun 2005 15:23:02 +0000 (+0000) Subject: Zero-ing the new HV array is pointless, as we write to every element. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a1cfa1c67270cd04b1ea57513e32792eca6c3d2b;p=p5sagit%2Fp5-mst-13.2.git Zero-ing the new HV array is pointless, as we write to every element. Also avoid calling into he_dup when the HE is 0, to save the function call overhead. p4raw-id: //depot/perl@24662 --- diff --git a/sv.c b/sv.c index 33584a3..30aa440 100644 --- a/sv.c +++ b/sv.c @@ -10926,18 +10926,18 @@ Perl_sv_dup(pTHX_ SV *sstr, CLONE_PARAMS* param) if (HvARRAY((HV*)sstr)) { STRLEN i = 0; + bool sharekeys = !!HvSHAREKEYS(sstr); XPVHV *dxhv = (XPVHV*)SvANY(dstr); XPVHV *sxhv = (XPVHV*)SvANY(sstr); char *darray; - /* FIXME - surely this doesn't need to be zeroed? */ - Newz(0, darray, + New(0, darray, PERL_HV_ARRAY_ALLOC_BYTES(dxhv->xhv_max+1) + (SvOOK(sstr) ? sizeof(struct xpvhv_aux) : 0), char); HvARRAY(dstr) = (HE**)darray; while (i <= sxhv->xhv_max) { + HE *source = HvARRAY(sstr)[i]; HvARRAY(dstr)[i] - = he_dup(HvARRAY(sstr)[i], - (bool)!!HvSHAREKEYS(sstr), param); + = source ? he_dup(source, sharekeys, param) : 0; ++i; } if (SvOOK(sstr)) {