diff options
author | Karl Williamson <khw@cpan.org> | 2020-08-19 11:57:17 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2020-08-19 16:12:19 -0600 |
commit | 87306e0674dfe3af29804b4641347cd5ac9b0521 (patch) | |
tree | 8693933fae0918d3570f6d4d412ac8d91eea5160 /inline.h | |
parent | 62066149de47fdbff345b71823d783ffad25933f (diff) | |
download | perl-87306e0674dfe3af29804b4641347cd5ac9b0521.tar.gz |
Add av_count()
This returns the number of elements in an array in a clearly named
function.
av_top_index(), av_tindex() are clearly named, but are less than ideal,
and came about because no one back then thought of this one, until now
Paul Evans did.
Diffstat (limited to 'inline.h')
-rw-r--r-- | inline.h | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -39,13 +39,21 @@ SOFTWARE. /* ------------------------------- av.h ------------------------------- */ -PERL_STATIC_INLINE SSize_t -Perl_av_top_index(pTHX_ AV *av) +/* +=for apidoc av_count +Returns the number of elements in the array C<av>. This is the true length of +the array, including any undefined elements. It is always the same as +S<C<av_top_index(av) + 1>>. + +=cut +*/ +PERL_STATIC_INLINE Size_t +Perl_av_count(pTHX_ AV *av) { - PERL_ARGS_ASSERT_AV_TOP_INDEX; + PERL_ARGS_ASSERT_AV_COUNT; assert(SvTYPE(av) == SVt_PVAV); - return AvFILL(av); + return AvFILL(av) + 1; } /* ------------------------------- cv.h ------------------------------- */ |