Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge preinc and postinc

They are almost identical.  This gives the compiler less code
to digest.
  • Loading branch information...
commit 17058fe0299db92774e157ee0067d1b500324e4f 1 parent 60092ce
Father Chrysostomos authored
Showing with 11 additions and 26 deletions.
  1. +4 −3 opcode.h
  2. +0 −17 pp.c
  3. +6 −3 pp_hot.c
  4. +0 −1  pp_proto.h
  5. +1 −2  regen/opcode.pl
View
7 opcode.h
@@ -22,7 +22,8 @@
#define Perl_pp_chomp Perl_pp_chop
#define Perl_pp_schomp Perl_pp_schop
#define Perl_pp_i_preinc Perl_pp_preinc
-#define Perl_pp_i_predec Perl_pp_predec
+#define Perl_pp_predec Perl_pp_preinc
+#define Perl_pp_i_predec Perl_pp_preinc
#define Perl_pp_i_postinc Perl_pp_postinc
#define Perl_pp_i_postdec Perl_pp_postdec
#define Perl_pp_slt Perl_pp_sle
@@ -967,8 +968,8 @@ EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */
Perl_pp_pos,
Perl_pp_preinc,
Perl_pp_i_preinc, /* implemented by Perl_pp_preinc */
- Perl_pp_predec,
- Perl_pp_i_predec, /* implemented by Perl_pp_predec */
+ Perl_pp_predec, /* implemented by Perl_pp_preinc */
+ Perl_pp_i_predec, /* implemented by Perl_pp_preinc */
Perl_pp_postinc,
Perl_pp_i_postinc, /* implemented by Perl_pp_postinc */
Perl_pp_postdec,
View
17 pp.c
@@ -1051,23 +1051,6 @@ PP(pp_undef)
RETPUSHUNDEF;
}
-PP(pp_predec)
-{
- dVAR; dSP;
- 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_MIN)
- {
- SvIV_set(TOPs, SvIVX(TOPs) - 1);
- SvFLAGS(TOPs) &= ~(SVp_NOK|SVp_POK);
- }
- else
- sv_dec(TOPs);
- SvSETMAGIC(TOPs);
- return NORMAL;
-}
-
PP(pp_postinc)
{
dVAR; dSP; dTARGET;
View
9 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;
}
View
1  pp_proto.h
@@ -170,7 +170,6 @@ PERL_CALLCONV OP *Perl_pp_pos(pTHX);
PERL_CALLCONV OP *Perl_pp_postdec(pTHX);
PERL_CALLCONV OP *Perl_pp_postinc(pTHX);
PERL_CALLCONV OP *Perl_pp_pow(pTHX);
-PERL_CALLCONV OP *Perl_pp_predec(pTHX);
PERL_CALLCONV OP *Perl_pp_preinc(pTHX);
PERL_CALLCONV OP *Perl_pp_print(pTHX);
PERL_CALLCONV OP *Perl_pp_prototype(pTHX);
View
3  regen/opcode.pl
@@ -116,8 +116,7 @@ BEGIN
Perl_pp_chop => [qw(chop chomp)],
Perl_pp_schop => [qw(schop schomp)],
Perl_pp_bind => {connect => '#ifdef HAS_SOCKET'},
- Perl_pp_preinc => ['i_preinc'],
- Perl_pp_predec => ['i_predec'],
+ Perl_pp_preinc => ['i_preinc', 'predec', 'i_predec'],
Perl_pp_postinc => ['i_postinc'],
Perl_pp_postdec => ['i_postdec'],
Perl_pp_ehostent => [qw(enetent eprotoent eservent
Please sign in to comment.
Something went wrong with that request. Please try again.