summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2009-05-18 11:57:38 +0100
committerNicholas Clark <nick@ccl4.org>2009-05-18 11:57:38 +0100
commit0228edf6a59a23f00e0f6eb4247cc4879f6bd150 (patch)
treebc9094abde9e7f7af7f0e038adb4c1814b6cf207 /sv.c
parentc160a1863eed093c75031c8196f07c0f13df1789 (diff)
downloadperl-0228edf6a59a23f00e0f6eb4247cc4879f6bd150.tar.gz
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.
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/sv.c b/sv.c
index 0b95142432..70e6a9b746 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;
}