From: Nicholas Clark Date: Mon, 18 May 2009 10:57:38 +0000 (+0100) Subject: In Perl_mg_dup(), remove a branch by tracking the address to write to instead of X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0228edf6a59a23f00e0f6eb4247cc4879f6bd150;p=p5sagit%2Fp5-mst-13.2.git In Perl_mg_dup(), remove a branch by tracking the address to write to instead of the address of the structure, with a special case for the first time round. --- diff --git a/sv.c b/sv.c index 0b95142..70e6a9b 100644 --- a/sv.c +++ b/sv.c @@ -10509,18 +10509,17 @@ Perl_gp_dup(pTHX_ GP *const gp, CLONE_PARAMS *const param) MAGIC * Perl_mg_dup(pTHX_ MAGIC *mg, CLONE_PARAMS *const param) { - MAGIC *mgprev = (MAGIC*)NULL; MAGIC *mgret = NULL; + MAGIC **mgprev_p = &mgret; PERL_ARGS_ASSERT_MG_DUP; for (; mg; mg = mg->mg_moremagic) { MAGIC *nmg; Newxz(nmg, 1, MAGIC); - if (mgprev) - mgprev->mg_moremagic = nmg; - else - mgret = nmg; + *mgprev_p = nmg; + mgprev_p = &(nmg->mg_moremagic); + nmg->mg_virtual = mg->mg_virtual; /* XXX copy dynamic vtable? */ nmg->mg_private = mg->mg_private; nmg->mg_type = mg->mg_type; @@ -10564,7 +10563,6 @@ Perl_mg_dup(pTHX_ MAGIC *mg, CLONE_PARAMS *const param) if ((mg->mg_flags & MGf_DUP) && mg->mg_virtual && mg->mg_virtual->svt_dup) { CALL_FPTR(nmg->mg_virtual->svt_dup)(aTHX_ nmg, param); } - mgprev = nmg; } return mgret; }