This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [PATCH] minor speed-up for pp_push()
authorTassilo von Parseval <tassilo.parseval@post.rwth-aachen.de>
Tue, 25 Oct 2005 08:11:42 +0000 (10:11 +0200)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Wed, 26 Oct 2005 10:21:30 +0000 (10:21 +0000)
Message-id: <20051025061141.GA2256@ethan>

p4raw-id: //depot/perl@25854

pp.c

diff --git a/pp.c b/pp.c
index db16281..834d32f 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -4333,18 +4333,19 @@ PP(pp_push)
        call_method("PUSH",G_SCALAR|G_DISCARD);
        LEAVE;
        SPAGAIN;
+       SP = ORIGMARK;
+       PUSHi( AvFILL(ary) + 1 );
     }
     else {
-       /* Why no pre-extend of ary here ? */
        for (++MARK; MARK <= SP; MARK++) {
            SV * const sv = NEWSV(51, 0);
            if (*MARK)
                sv_setsv(sv, *MARK);
-           av_push(ary, sv);
+           av_store(ary, AvFILLp(ary)+1, sv);
        }
+       SP = ORIGMARK;
+       PUSHi( AvFILLp(ary) + 1 );
     }
-    SP = ORIGMARK;
-    PUSHi( AvFILL(ary) + 1 );
     RETURN;
 }