diff options
author | David Mitchell <davem@iabyn.com> | 2019-02-04 15:07:11 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2019-02-05 14:03:05 +0000 |
commit | 0872de45fff4b1f6c17e1d5bec82d3d5095801a2 (patch) | |
tree | df3784390ce43b1f7a0b401f97bde5136fe7f408 /gv.c | |
parent | 9b2983ca78e5369d17559ca0aa5af58e9da3724a (diff) | |
download | perl-0872de45fff4b1f6c17e1d5bec82d3d5095801a2.tar.gz |
Eliminate AMGf_set flag
I added this flag a few years ago when I revamped the overload macros
tryAMAGICbin() etc. It allowed two different classes of macros to
share the same functions (Perl_try_amagic_un/Perl_try_amagic_bin)
by indicating what type of action is required.
However, the last few commits have made those two functions able to
robustly always determine whether its an assign-type action
($x op= $y or $lex = $x op $x) or a plain set-result-on-stack operation
($x op $y).
So eliminate this flag.
Note that this makes the ops which have the AMGf_set flag hard-coded
infinitesimally slower, since Perl_try_amagic_bin no longer skips the
checks for assign-ness. But compared with the overhead of having
already called the overload method, this is is trivial.
On the plus side, it makes the code smaller and easier to understand.
Diffstat (limited to 'gv.c')
-rw-r--r-- | gv.c | 15 |
1 files changed, 2 insertions, 13 deletions
@@ -2938,8 +2938,6 @@ Perl_gv_handler(pTHX_ HV *stash, I32 id) /* Implement tryAMAGICun_MG macro. Do get magic, then see if the stack arg is overloaded and if so call it. Flags: - AMGf_set return the arg using SETs rather than assigning to - the targ AMGf_numeric apply sv_2num to the stack arg. */ @@ -2955,10 +2953,7 @@ Perl_try_amagic_un(pTHX_ int method, int flags) { AMGf_noright | AMGf_unary | (flags & AMGf_numarg)))) { - if (flags & AMGf_set) { - SETs(tmpsv); - } - else { + { /* where the op is of the form: * $lex = $x op $y (where the assign is optimised away) * then assign the returned value to targ and return that; @@ -2988,8 +2983,6 @@ Perl_try_amagic_un(pTHX_ int method, int flags) { Do get magic, then see if the two stack args are overloaded and if so call it. Flags: - AMGf_set return the arg using SETs rather than assigning to - the targ AMGf_assign op may be called as mutator (eg +=) AMGf_numeric apply sv_2num to the stack arg. */ @@ -3013,11 +3006,7 @@ Perl_try_amagic_bin(pTHX_ int method, int flags) { (mutator ? AMGf_assign: 0) | (flags & AMGf_numarg)); if (tmpsv) { - if (flags & AMGf_set) { - (void)POPs; - SETs(tmpsv); - } - else { + { (void)POPs; /* where the op is one of the two forms: * $x op= $y |