diff options
author | David Mitchell <davem@iabyn.com> | 2015-10-25 18:28:14 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2015-11-10 13:52:34 +0000 |
commit | 20e9643135b0912e2449f038a0ec1c0e84657f3f (patch) | |
tree | f30b419cd8f5a714a3479cc3fc13bf303549e955 /pp_proto.h | |
parent | 4c2c31284ee422eca648d182e07205f67a173227 (diff) | |
download | perl-20e9643135b0912e2449f038a0ec1c0e84657f3f.tar.gz |
split pp_postdec() from pp_postinc() and improve
pp_postinc() handles both $x++ and $x-- (and the integer variants
pp_i_postinc/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) did a sv_setsv(TARG, TOPs) to return a copy of the original value;
2) checked for a IOK-only SV and if so, directly incremented the IVX slot;
3) else called out to sv_inc/dec() to handle the more complex cases.
This commit combines the checks in (1) and (3) into one single big
check of flags, and for the simple integer case, skips 2) and does
a more efficient SETi() instead.
For the non-simple case, both pp_postinc() and pp_postdec() now call a
common static function to handle everything else.
Porting/bench.pl shows the following raw numbers for
'$y = $x++' ($x and $y lexical and holding integers):
before after
------ -----
Ir 306.0 223.0
Dr 106.0 82.0
Dw 51.0 44.0
COND 48.0 33.0
IND 8.0 6.0
COND_m 1.9 0.0
IND_m 4.0 4.0
Diffstat (limited to 'pp_proto.h')
-rw-r--r-- | pp_proto.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/pp_proto.h b/pp_proto.h index 440e7899cb..f919313ed1 100644 --- a/pp_proto.h +++ b/pp_proto.h @@ -184,6 +184,7 @@ PERL_CALLCONV OP *Perl_pp_padrange(pTHX); PERL_CALLCONV OP *Perl_pp_padsv(pTHX); PERL_CALLCONV OP *Perl_pp_pipe_op(pTHX); 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); |