diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-09-16 16:10:57 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-09-16 16:14:23 -0700 |
commit | 17058fe0299db92774e157ee0067d1b500324e4f (patch) | |
tree | 877e5f6b8a41de84bab6506a8a622721b027da6b | |
parent | 60092ce4854ea5801a4711d82d0e2c57a7edcaca (diff) | |
download | perl-17058fe0299db92774e157ee0067d1b500324e4f.tar.gz |
Merge preinc and postinc
They are almost identical. This gives the compiler less code
to digest.
-rw-r--r-- | opcode.h | 7 | ||||
-rw-r--r-- | pp.c | 17 | ||||
-rw-r--r-- | pp_hot.c | 9 | ||||
-rw-r--r-- | pp_proto.h | 1 | ||||
-rwxr-xr-x | regen/opcode.pl | 3 |
5 files changed, 11 insertions, 26 deletions
@@ -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, @@ -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; @@ -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; } diff --git a/pp_proto.h b/pp_proto.h index 5e19fc3120..e795c8ad51 100644 --- a/pp_proto.h +++ b/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); diff --git a/regen/opcode.pl b/regen/opcode.pl index b4576da236..5c81ec37d7 100755 --- a/regen/opcode.pl +++ b/regen/opcode.pl @@ -116,8 +116,7 @@ my @raw_alias = ( 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 |