diff options
author | David Mitchell <davem@iabyn.com> | 2017-07-04 09:45:29 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2017-07-27 11:30:21 +0100 |
commit | 725c44f93c35f696d7175c36a6d2ec5987b5a4d1 (patch) | |
tree | 721f07a19addb4cffc53b5d7736dae71f68c01fb /gv.c | |
parent | b043c4bf3fff5c679dad74f1a0c13ac539a97815 (diff) | |
download | perl-725c44f93c35f696d7175c36a6d2ec5987b5a4d1.tar.gz |
use the new PL_sv_zero in obvious places
In places that do things like mPUSHi(0) or newSViv(0), replace them
with PUSHs(&PL_sv_zero) and &PL_sv_zero, etc.
This avoids the cost of creating and/or mortalising an SV, and/or setting
its value to 0.
This commit causes a subtle change to tainting in various places as a
side-effect. For example, grep in scalar context retunrs 0 if it has no
args. Formerly the zero value could in theory get tainted:
@a = ();
$x = ( ($^X . ""), grep { 1 } @a);
It used to be the case that $x would be tainted; now its not.
In practice this doesn't matter - the zero value was only getting tainted
as a side-effect of tainting's "if anything in the statement uses a
tainted value, taint everything" mechanism, which gives (documented) false
positives. This commit merely removes some such false positives, and
makes the behaviour similar to functions which return &PL_sv_undef/no/yes,
which are also immune to side-effect tainting.
Diffstat (limited to 'gv.c')
-rw-r--r-- | gv.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -3180,7 +3180,7 @@ Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags) case abs_amg: if ((cvp[off1=lt_amg] || cvp[off1=ncmp_amg]) && ((cv = cvp[off=neg_amg]) || (cv = cvp[off=subtr_amg]))) { - SV* const nullsv=sv_2mortal(newSViv(0)); + SV* const nullsv=&PL_sv_zero; if (off1==lt_amg) { SV* const lessp = amagic_call(left,nullsv, lt_amg,AMGf_noright); @@ -3204,7 +3204,7 @@ Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags) case neg_amg: if ((cv = cvp[off=subtr_amg])) { right = left; - left = sv_2mortal(newSViv(0)); + left = &PL_sv_zero; lr = 1; } break; |