diff options
author | David Mitchell <davem@iabyn.com> | 2019-02-04 13:48:13 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2019-02-05 14:03:05 +0000 |
commit | 72876cce4ecc7d8756e00d284e32df0b943d0da9 (patch) | |
tree | eb2fbf4d5389c41ab464221a1089a9eb00429389 /gv.c | |
parent | 35c1827fadfaf0a26b8d1373f06ee242ee79c111 (diff) | |
download | perl-72876cce4ecc7d8756e00d284e32df0b943d0da9.tar.gz |
Eliminate opASSIGN macro usage from core
This macro is defined as
(PL_op->op_flags & OPf_STACKED)
and indicates, for ops which support it, that the mutator-variant of the
op is present (e.g. $x += 1).
This macro was mainly used as an arg for the old-style overloading
macros (tryAMAGICbin()) which were eliminated several years ago.
This commit removes its vestigial usage, and instead tests OPf_STACKED
directly at each location, along with adding a comment about the
significance of the flag.
This removes one item of obfuscation from the overloading code.
There is one potentially functional change in this commit:
Perl_try_amagic_bin() was sometimes testing for OPf_STACKED without
first checking that it had been called with the AMGf_assign flag (which
indicates that this op supports a mutator variant). With this commit, it
now checks first, so this is theoretically a bug fix. In practice that
section of code was never reached without AMGf_assign always being set
anyway.
Diffstat (limited to 'gv.c')
-rw-r--r-- | gv.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -2998,8 +2998,12 @@ Perl_try_amagic_bin(pTHX_ int method, int flags) { SvGETMAGIC(right); if (SvAMAGIC(left) || SvAMAGIC(right)) { - SV * const tmpsv = amagic_call(left, right, method, - ((flags & AMGf_assign) && opASSIGN ? AMGf_assign: 0) + SV * tmpsv; + /* STACKED implies mutator variant, e.g. $x += 1 */ + bool mutator = (flags & AMGf_assign) && (PL_op->op_flags & OPf_STACKED); + + tmpsv = amagic_call(left, right, method, + (mutator ? AMGf_assign: 0) | (flags & AMGf_numarg)); if (tmpsv) { if (flags & AMGf_set) { @@ -3009,7 +3013,7 @@ Perl_try_amagic_bin(pTHX_ int method, int flags) { else { dATARGET; (void)POPs; - if (opASSIGN || SvPADMY(TARG)) { + if (mutator || SvPADMY(TARG)) { sv_setsv(TARG, tmpsv); SETTARG; } |