summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-12-27 11:41:10 +0000
committerNicholas Clark <nick@ccl4.org>2010-12-27 11:41:10 +0000
commitfa54efaecf052db2a7799ec4c2433eeb1576402e (patch)
tree3867f9cf190015546695148d265fe7b9c2ca50e0 /pp.c
parentfc51b17cb579e8cdaf6e99fdeb80f92379491759 (diff)
downloadperl-fa54efaecf052db2a7799ec4c2433eeb1576402e.tar.gz
Merge the opcode bodies for chop/chomp and schop/schomp.
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c31
1 files changed, 9 insertions, 22 deletions
diff --git a/pp.c b/pp.c
index 573672d54e..1e2c79f5ed 100644
--- a/pp.c
+++ b/pp.c
@@ -794,7 +794,11 @@ PP(pp_trans)
PP(pp_schop)
{
dVAR; dSP; dTARGET;
- do_chomp(TARG, TOPs, FALSE);
+ const bool chomping = PL_op->op_type == OP_SCHOMP;
+
+ if (chomping)
+ sv_setiv(TARG, 0);
+ do_chomp(TARG, TOPs, chomping);
SETTARG;
RETURN;
}
@@ -802,29 +806,12 @@ PP(pp_schop)
PP(pp_chop)
{
dVAR; dSP; dMARK; dTARGET; dORIGMARK;
- while (MARK < SP)
- do_chomp(TARG, *++MARK, FALSE);
- SP = ORIGMARK;
- XPUSHTARG;
- RETURN;
-}
+ const bool chomping = PL_op->op_type == OP_CHOMP;
-PP(pp_schomp)
-{
- dVAR; dSP; dTARGET;
- sv_setiv(TARG, 0);
- do_chomp(TARG, TOPs, TRUE);
- SETs(TARG);
- RETURN;
-}
-
-PP(pp_chomp)
-{
- dVAR; dSP; dMARK; dTARGET; dORIGMARK;
-
- sv_setiv(TARG, 0);
+ if (chomping)
+ sv_setiv(TARG, 0);
while (MARK < SP)
- do_chomp(TARG, *++MARK, TRUE);
+ do_chomp(TARG, *++MARK, chomping);
SP = ORIGMARK;
XPUSHTARG;
RETURN;