diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-05-30 11:51:15 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-05-30 11:55:42 +0100 |
commit | 77bac227771c643a8a6e305b2bac4665a8f772d1 (patch) | |
tree | e3cc6f832c152ed512729dd78a483d833c06d00b /pad.c | |
parent | c85ae797ecb755d3bcfabd44aa268e3e6e2e7c13 (diff) | |
download | perl-77bac227771c643a8a6e305b2bac4665a8f772d1.tar.gz |
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.
Diffstat (limited to 'pad.c')
-rw-r--r-- | pad.c | 3 |
1 files changed, 0 insertions, 3 deletions
@@ -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); |