diff options
author | Karl Williamson <public@khwilliamson.com> | 2012-12-27 15:21:47 -0700 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2013-01-19 22:53:04 -0700 |
commit | 36baafc9b54ecc5cdea82552276a70b5218958bb (patch) | |
tree | b2f6e8c58190cd81605b11b9c2e6139fb53ee13b /av.c | |
parent | 8fb629dbc35ef4d5ec17062231fd1a79dc5a0a75 (diff) | |
download | perl-36baafc9b54ecc5cdea82552276a70b5218958bb.tar.gz |
Add av_top() synonym for av_len()
av_len() is misleadingly named.
Diffstat (limited to 'av.c')
-rw-r--r-- | av.c | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -759,25 +759,45 @@ Perl_av_shift(pTHX_ AV *av) } /* -=for apidoc av_len +=for apidoc av_top Returns the highest index in the array. The number of elements in the -array is C<av_len(av) + 1>. Returns -1 if the array is empty. +array is C<av_top(av) + 1>. Returns -1 if the array is empty. The Perl equivalent for this is C<$#myarray>. +=for apidoc av_len + +Same as L</av_top>. Returns the highest index in the array. Note that the +return value is +1 what its name implies it returns; and hence differs in +meaning from what the similarly named L</sv_len> returns. + =cut */ I32 Perl_av_len(pTHX_ AV *av) { + /* If change this, must change identical Perl_av_top() just below */ + PERL_ARGS_ASSERT_AV_LEN; assert(SvTYPE(av) == SVt_PVAV); return AvFILL(av); } +I32 +Perl_av_top(pTHX_ AV *av) +{ + /* So short, that it is just a duplicate of Perl_av_len(). Must keep them + * in sync */ + + PERL_ARGS_ASSERT_AV_TOP; + assert(SvTYPE(av) == SVt_PVAV); + + return AvFILL(av); +} + /* =for apidoc av_fill |