diff options
author | David Mitchell <davem@iabyn.com> | 2017-12-19 15:28:06 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2017-12-19 15:28:06 +0000 |
commit | 04d596853d450fae95e059c4d4d15f6750beea34 (patch) | |
tree | 9ef1c3a2b2f187c5a9192e4614d0893a4ccad5d4 /pp_hot.c | |
parent | 5e501dc57f49d52e0f2a302181be287457c0b736 (diff) | |
download | perl-04d596853d450fae95e059c4d4d15f6750beea34.tar.gz |
s/// in boolean context: simplify return value
Normally s/// returns a count of the number of iterations, but
as an optimisation, in boolean context it returns PL_sv_yes/PL_sv_zero
instead. But in the places where it decides which immortal var to return,
the number of iterations is always > 0, so PL_sv_zero never gets returned.
So skip testing whether iters > 0 and always just return PL_sv_yes.
(In non-boolean scalar context, it still returns the iteration count as
before.)
Diffstat (limited to 'pp_hot.c')
-rw-r--r-- | pp_hot.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -4361,8 +4361,9 @@ PP(pp_subst) Move(s, d, i+1, char); /* include the NUL */ } SPAGAIN; + assert(iters); if (PL_op->op_private & OPpTRUEBOOL) - PUSHs(iters ? &PL_sv_yes : &PL_sv_zero); + PUSHs(&PL_sv_yes); else mPUSHi(iters); } @@ -4471,7 +4472,7 @@ PP(pp_subst) SPAGAIN; if (PL_op->op_private & OPpTRUEBOOL) - PUSHs(iters ? &PL_sv_yes : &PL_sv_zero); + PUSHs(&PL_sv_yes); else mPUSHi(iters); } |