diff options
author | Richard Leach <richardleach@users.noreply.github.com> | 2022-03-20 15:22:27 +0000 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2022-06-08 09:41:44 -0600 |
commit | eae3cc9643eecd5d8b27c8fb4a3dc3bfebaf57e3 (patch) | |
tree | f391916870180d03e3af0e59ae164360c2615c02 /av.c | |
parent | a9b64e60085410a21f22d9df311cfe251b44d446 (diff) | |
download | perl-eae3cc9643eecd5d8b27c8fb4a3dc3bfebaf57e3.tar.gz |
Move av_new_alloc from av.c to inline.h
There was less benefit in doing this prior to newSV_type becoming an inline
function. Now that it is, inlining av_new_alloc can help compilers eliminate
redundant setting of AvMAX/AvFILLp and unnecessary branches of any following
inlined calls to av_store_simple.
Diffstat (limited to 'av.c')
-rw-r--r-- | av.c | 42 |
1 files changed, 0 insertions, 42 deletions
@@ -393,48 +393,6 @@ Perl_av_store(pTHX_ AV *av, SSize_t key, SV *val) } /* -=for apidoc av_new_alloc - -This implements L<perlapi/C<newAV_alloc_x>> -and L<perlapi/C<newAV_alloc_xz>>, which are the public API for this -functionality. - -Creates a new AV and allocates its SV* array. - -This is similar to, but more efficient than doing: - - AV *av = newAV(); - av_extend(av, key); - -The size parameter is used to pre-allocate a SV* array large enough to -hold at least elements C<0..(size-1)>. C<size> must be at least 1. - -The C<zeroflag> parameter controls whether or not the array is NULL -initialized. - -=cut -*/ - -AV * -Perl_av_new_alloc(pTHX_ SSize_t size, bool zeroflag) -{ - AV * const av = newAV(); - SV** ary; - PERL_ARGS_ASSERT_AV_NEW_ALLOC; - assert(size > 0); - - Newx(ary, size, SV*); /* Newx performs the memwrap check */ - AvALLOC(av) = ary; - AvARRAY(av) = ary; - AvMAX(av) = size - 1; - - if (zeroflag) - Zero(ary, size, SV*); - - return av; -} - -/* =for apidoc av_make Creates a new AV and populates it with a list (C<**strp>, length C<size>) of |