This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pre{inc,dec} is faster, even with integers
authorHugo van der Sanden <hv@crypt.org>
Fri, 14 Oct 2005 18:22:41 +0000 (19:22 +0100)
committerNicholas Clark <nick@ccl4.org>
Sat, 15 Oct 2005 21:35:29 +0000 (21:35 +0000)
Message-Id: <200510141722.j9EHMfa25945@zen.crypt.org>
Date: Fri, 14 Oct 2005 18:22:41 +0100

p4raw-id: //depot/perl@25763

op.c
t/op/inc.t

diff --git a/op.c b/op.c
index 6b29e3c..7272538 100644 (file)
--- 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:
index 7d6ebab..3eec5cd 100755 (executable)
@@ -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");
+}