From 726d34943e707eeb7fe717fba1189390ec3208e2 Mon Sep 17 00:00:00 2001 From: Ben Tilly Date: Tue, 21 Nov 2000 18:29:31 -0500 Subject: Re: av.c patch (having slight problems) Message-ID: unshift() speedup. p4raw-id: //depot/perl@7825 --- av.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'av.c') diff --git a/av.c b/av.c index 777651d2fb..e5f6dc8d7a 100644 --- a/av.c +++ b/av.c @@ -554,6 +554,7 @@ Perl_av_unshift(pTHX_ register AV *av, register I32 num) register I32 i; register SV **ary; MAGIC* mg; + I32 slide; if (!av || num <= 0) return; @@ -591,6 +592,9 @@ Perl_av_unshift(pTHX_ register AV *av, register I32 num) } if (num) { i = AvFILLp(av); + /* Create extra elements */ + slide = i > 0 ? i : 0; + num += slide; av_extend(av, i + num); AvFILLp(av) += num; ary = AvARRAY(av); @@ -598,6 +602,10 @@ Perl_av_unshift(pTHX_ register AV *av, register I32 num) do { ary[--num] = &PL_sv_undef; } while (num); + /* Make extra elements into a buffer */ + AvMAX(av) -= slide; + AvFILLp(av) -= slide; + SvPVX(av) = (char*)(AvARRAY(av) + slide); } } -- cgit v1.2.1