From: Nicholas Clark Date: Sun, 30 May 2010 10:51:15 +0000 (+0100) Subject: Only allocate entries for @_ when the subroutine is first called. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=77bac227771c643a8a6e305b2bac4665a8f772d1;p=p5sagit%2Fp5-mst-13.2.git Only allocate entries for @_ when the subroutine is first called. Previously, @_ was allocated for every subroutine at compile time, with a default sized AV, hence space for 4 entries. We don't actually need to allocate the space for entries, as there is already a check at call time as to whether @_ is long enough. valgrind suggests that this saves allocating 23K (on a 64 bit platform) when running pod2man on perlfunc.pod. As well as the absolute saving, there is also benefit in deferring allocation for subroutines actually called - for a program which forks, @_ is less likely to be in pages shared COW with the parent. Resolves RT #72416. --- diff --git a/pad.c b/pad.c index 8015154..f297e54 100644 --- a/pad.c +++ b/pad.c @@ -200,7 +200,6 @@ Perl_pad_new(pTHX_ int flags) */ AV * const a0 = newAV(); /* will be @_ */ - av_extend(a0, 0); av_store(pad, 0, MUTABLE_SV(a0)); AvREIFY_only(a0); } @@ -1299,7 +1298,6 @@ Perl_pad_tidy(pTHX_ padtidy_type type) else if (type == padtidy_SUB) { /* XXX DAPM this same bit of code keeps appearing !!! Rationalise? */ AV * const av = newAV(); /* Will be @_ */ - av_extend(av, 0); av_store(PL_comppad, 0, MUTABLE_SV(av)); AvREIFY_only(av); } @@ -1742,7 +1740,6 @@ Perl_pad_push(pTHX_ PADLIST *padlist, int depth) } } av = newAV(); - av_extend(av, 0); av_store(newpad, 0, MUTABLE_SV(av)); AvREIFY_only(av);