summaryrefslogtreecommitdiff
path: root/opcode.h
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2015-10-25 08:41:50 +0000
committerDavid Mitchell <davem@iabyn.com>2015-11-10 13:52:34 +0000
commit4c2c31284ee422eca648d182e07205f67a173227 (patch)
tree75ed516c3acfcb5c67e98cf201a97d813fbf326e /opcode.h
parent230ee21f3e366901ce5769d324124c522df7ce8a (diff)
downloadperl-4c2c31284ee422eca648d182e07205f67a173227.tar.gz
split pp_predec() from pp_preinc() and improve
pp_preinc() handles both ++$x and --$x (and the integer variants pp_i_preinc/dec). Split it into two separate functions, as handling both inc and dec in the same function requires 3 extra conditionals. At the same time make the code more efficient. As currently written it: 1) checked for "bad" SVs (such as read-only) and croaked; 2) checked for a IOK-only SV and directly incremented the IVX slot; 3) else called out to sv_inc() to handle the more complex cases. This commit combines the checks in (1) and (2) into one single big check of flags, and anything "bad" simply skips the IOK-only code and calls sv_dec(), which can do its own checking of read-only etc and croak if necessary. Porting/bench.pl shows the following raw numbers for ++$x ($x lexical and holding an integer): before after -------- -------- Ir 77.0 56.0 Dr 30.0 24.0 Dw 10.0 10.0 COND 12.0 9.0 IND 2.0 2.0 COND_m -0.1 0.0 IND_m 2.0 2.0 Even having split the function into two, the combined size of the two new functions is smaller than the single previous function.
Diffstat (limited to 'opcode.h')
-rw-r--r--opcode.h7
1 files changed, 3 insertions, 4 deletions
diff --git a/opcode.h b/opcode.h
index 2e03448be5..01ed42d958 100644
--- a/opcode.h
+++ b/opcode.h
@@ -22,8 +22,7 @@
#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_predec Perl_pp_preinc
-#define Perl_pp_i_predec Perl_pp_preinc
+#define Perl_pp_i_predec Perl_pp_predec
#define Perl_pp_i_postinc Perl_pp_postinc
#define Perl_pp_postdec Perl_pp_postinc
#define Perl_pp_i_postdec Perl_pp_postinc
@@ -1013,8 +1012,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, /* implemented by Perl_pp_preinc */
- Perl_pp_i_predec, /* implemented by Perl_pp_preinc */
+ Perl_pp_predec,
+ Perl_pp_i_predec, /* implemented by Perl_pp_predec */
Perl_pp_postinc,
Perl_pp_i_postinc, /* implemented by Perl_pp_postinc */
Perl_pp_postdec, /* implemented by Perl_pp_postinc */