From: Hugo van der Sanden Date: Fri, 14 Oct 2005 18:22:41 +0000 (+0100) Subject: pre{inc,dec} is faster, even with integers X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=679d6c4eed9fff03ad56a76e8f8ed516c6e0deb2;p=p5sagit%2Fp5-mst-13.2.git pre{inc,dec} is faster, even with integers Message-Id: <200510141722.j9EHMfa25945@zen.crypt.org> Date: Fri, 14 Oct 2005 18:22:41 +0100 p4raw-id: //depot/perl@25763 --- diff --git a/op.c b/op.c index 6b29e3c..7272538 100644 --- a/op.c +++ b/op.c @@ -804,6 +804,16 @@ Perl_scalarvoid(pTHX_ OP *o) o->op_ppaddr = PL_ppaddr[OP_PREDEC]; break; + case OP_I_POSTINC: + o->op_type = OP_I_PREINC; /* pre-increment is faster */ + o->op_ppaddr = PL_ppaddr[OP_I_PREINC]; + break; + + case OP_I_POSTDEC: + o->op_type = OP_I_PREDEC; /* pre-decrement is faster */ + o->op_ppaddr = PL_ppaddr[OP_I_PREDEC]; + break; + case OP_OR: case OP_AND: case OP_DOR: diff --git a/t/op/inc.t b/t/op/inc.t index 7d6ebab..3eec5cd 100755 --- a/t/op/inc.t +++ b/t/op/inc.t @@ -2,7 +2,7 @@ # use strict; -print "1..32\n"; +print "1..34\n"; my $test = 1; @@ -185,3 +185,12 @@ ok ($a == 2147483647, $a); $a = 2147483648; $c=$a--; ok ($a == 2147483647, $a); + +{ + use integer; + my $x = 0; + $x++; + ok ($x == 1, "(void) i_postinc"); + $x--; + ok ($x == 0, "(void) i_postdec"); +}