diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-11-16 11:42:01 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-11-16 11:42:01 +0000 |
commit | 7a6072a8e020194545ae918018728beca4bd5e3b (patch) | |
tree | 4ffa86f8cbadfc346dc6fe386e97a20395bc2e7d /pad.c | |
parent | 403799bf19538009b2d9e762e57456168d29ca0e (diff) | |
download | perl-7a6072a8e020194545ae918018728beca4bd5e3b.tar.gz |
In Perl_pad_new(), allocate a 2 element array for padlist.
Most subroutines never recurse, hence only need 2 entries in the padlist
array - names, and depth=1. The default for av_store() is to allocate 0..3,
and even an explicit call to av_extend() with <3 will be rounded up, so we
inline the allocation of the array here.
Running ./installman allocates 7K less with this change.
Diffstat (limited to 'pad.c')
-rw-r--r-- | pad.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -160,6 +160,7 @@ Perl_pad_new(pTHX_ int flags) { dVAR; AV *padlist, *padname, *pad; + SV **ary; ASSERT_CURPAD_LEGAL("pad_new"); @@ -209,8 +210,17 @@ Perl_pad_new(pTHX_ int flags) } AvREAL_off(padlist); - av_store(padlist, 0, MUTABLE_SV(padname)); - av_store(padlist, 1, MUTABLE_SV(pad)); + /* Most subroutines never recurse, hence only need 2 entries in the padlist + array - names, and depth=1. The default for av_store() is to allocate + 0..3, and even an explicit call to av_extend() with <3 will be rounded + up, so we inline the allocation of the array here. */ + Newx(ary, 2, SV*); + AvFILLp(padlist) = 1; + AvMAX(padlist) = 1; + AvALLOC(padlist) = ary; + AvARRAY(padlist) = ary; + ary[0] = MUTABLE_SV(padname); + ary[1] = MUTABLE_SV(pad); /* ... then update state variables */ |