summaryrefslogtreecommitdiff
path: root/av.c
diff options
context:
space:
mode:
authorBen Tilly <ben_tilly@operamail.com>2000-11-21 18:29:31 -0500
committerJarkko Hietaniemi <jhi@iki.fi>2000-11-23 00:20:41 +0000
commite2b534e73737788b0d66a6d8380a5af970286238 (patch)
tree92f556a361306d87dc13da93f7f27aa827eee157 /av.c
parent793db0cbf2a1f8691eefd9130892b47143e8795f (diff)
downloadperl-e2b534e73737788b0d66a6d8380a5af970286238.tar.gz
Re: av.c patch (having slight problems)
Message-ID: <LAW2-F113pL32ctFfj800000d81@hotmail.com> unshift() speedup. p4raw-id: //depot/perl@7825
Diffstat (limited to 'av.c')
-rw-r--r--av.c8
1 files changed, 8 insertions, 0 deletions
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);
}
}