This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Perl_try_amagic_bin(): eliminate dATARGET
authorDavid Mitchell <davem@iabyn.com>
Mon, 4 Feb 2019 14:52:01 +0000 (14:52 +0000)
committerDavid Mitchell <davem@iabyn.com>
Tue, 5 Feb 2019 14:03:05 +0000 (14:03 +0000)
.. and replace with explicit tests and assigns to targ.

This macro includes an OPf_STACKED test which has already been done
above.  Also, by protecting the OPf_STACKED test within a AMGf_assign
test, we can eliminate the AMGf_set flag in the next commit, and use the
same set of code for both AMGf_set and AMGf_assign variant calls to
Perl_try_amagic_bin().

gv.c

diff --git a/gv.c b/gv.c
index 7808c53..683a9f0 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -3018,7 +3018,6 @@ Perl_try_amagic_bin(pTHX_ int method, int flags) {
                SETs(tmpsv);
            }
            else {
-               dATARGET;
                (void)POPs;
                 /* where the op is one of the two forms:
                  *    $x op= $y
@@ -3030,6 +3029,8 @@ Perl_try_amagic_bin(pTHX_ int method, int flags) {
                     || (   (PL_opargs[PL_op->op_type] & OA_TARGLEX)
                         && (PL_op->op_private & OPpTARGET_MY)))
                 {
+                    dTARG;
+                    TARG = mutator ? *SP : PAD_SV(PL_op->op_targ);
                    sv_setsv(TARG, tmpsv);
                    SETTARG;
                }