summaryrefslogtreecommitdiff
path: root/pp_hot.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-09-16 16:10:57 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-09-16 16:14:23 -0700
commit17058fe0299db92774e157ee0067d1b500324e4f (patch)
tree877e5f6b8a41de84bab6506a8a622721b027da6b /pp_hot.c
parent60092ce4854ea5801a4711d82d0e2c57a7edcaca (diff)
downloadperl-17058fe0299db92774e157ee0067d1b500324e4f.tar.gz
Merge preinc and postinc
They are almost identical. This gives the compiler less code to digest.
Diffstat (limited to 'pp_hot.c')
-rw-r--r--pp_hot.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/pp_hot.c b/pp_hot.c
index 594d114f52..59fc443078 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -362,16 +362,19 @@ PP(pp_eq)
PP(pp_preinc)
{
dVAR; dSP;
+ const bool inc =
+ PL_op->op_type == OP_PREINC || PL_op->op_type == OP_I_PREINC;
if (SvTYPE(TOPs) >= SVt_PVAV || (isGV_with_GP(TOPs) && !SvFAKE(TOPs)))
Perl_croak_no_modify(aTHX);
if (!SvREADONLY(TOPs) && SvIOK_notUV(TOPs) && !SvNOK(TOPs) && !SvPOK(TOPs)
- && SvIVX(TOPs) != IV_MAX)
+ && SvIVX(TOPs) != (inc ? IV_MAX : IV_MIN))
{
- SvIV_set(TOPs, SvIVX(TOPs) + 1);
+ SvIV_set(TOPs, SvIVX(TOPs) + (inc ? 1 : -1));
SvFLAGS(TOPs) &= ~(SVp_NOK|SVp_POK);
}
else /* Do all the PERL_PRESERVE_IVUV conditionals in sv_inc */
- sv_inc(TOPs);
+ if (inc) sv_inc(TOPs);
+ else sv_dec(TOPs);
SvSETMAGIC(TOPs);
return NORMAL;
}