s///: return boolean in not-in-place branch
authorDavid Mitchell <davem@iabyn.com>
Tue, 19 Dec 2017 12:09:15 +0000 (12:09 +0000)
committerDavid Mitchell <davem@iabyn.com>
Tue, 19 Dec 2017 15:15:02 +0000 (15:15 +0000)
A while back, s/// (and other ops) were optimised to return
PL_sv_yes/PL_sv_zero rather than an iteration count in boolean context.

This optimisation was missed in one place in pp_subst(): the 'can modify
in place' branch was done, but the other branch was missed.

This commit fixes that.

pp_hot.c

index 100ae39..958aa6e 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -4470,7 +4470,10 @@ PP(pp_subst)
            SvPV_set(dstr, NULL);
 
            SPAGAIN;
-           mPUSHi(iters);
+            if (PL_op->op_private & OPpTRUEBOOL)
+                PUSHs(iters ? &PL_sv_yes : &PL_sv_zero);
+            else
+                mPUSHi(iters);
        }
     }