This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Use av_top_index() instead of av_tindex()
authorKarl Williamson <khw@cpan.org>
Thu, 20 Aug 2020 01:06:01 +0000 (19:06 -0600)
committerKarl Williamson <khw@cpan.org>
Thu, 20 Aug 2020 01:11:45 +0000 (19:11 -0600)
I was never happy with this short form, and other people weren't either.
Now that most things are better expressed in terms of av_count, convert
the few remaining items that are clearer when referring to an index into
using the fully spelled out form

op.c
op.h
pp.c
pp_hot.c
regexec.c
universal.c

diff --git a/op.c b/op.c
index 49aac85..38a55f9 100644 (file)
--- a/op.c
+++ b/op.c
@@ -8143,7 +8143,7 @@ Perl_newPMOP(pTHX_ I32 type, I32 flags)
     } else {
        SV * const repointer = &PL_sv_undef;
        av_push(PL_regex_padav, repointer);
-       pmop->op_pmoffset = av_tindex(PL_regex_padav);
+       pmop->op_pmoffset = av_top_index(PL_regex_padav);
        PL_regex_pad = AvARRAY(PL_regex_padav);
     }
 #endif
diff --git a/op.h b/op.h
index 3264aeb..d660c84 100644 (file)
--- a/op.h
+++ b/op.h
@@ -816,7 +816,7 @@ preprocessing token; the type of C<arg> depends on C<which>.
     STMT_START { \
        if (PL_blockhooks) { \
            SSize_t i; \
-           for (i = av_tindex(PL_blockhooks); i >= 0; i--) { \
+           for (i = av_top_index(PL_blockhooks); i >= 0; i--) { \
                SV *sv = AvARRAY(PL_blockhooks)[i]; \
                BHK *hk; \
                \
diff --git a/pp.c b/pp.c
index 1c387d5..f836b16 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -4988,7 +4988,7 @@ PP(pp_aeach)
     IV *iterp = Perl_av_iter_p(aTHX_ array);
     const IV current = (*iterp)++;
 
-    if (current > av_tindex(array)) {
+    if (current > av_top_index(array)) {
        *iterp = 0;
        if (gimme == G_SCALAR)
            RETPUSHUNDEF;
@@ -5859,7 +5859,7 @@ PP(pp_reverse)
                const MAGIC *mg;
                bool can_preserve = SvCANEXISTDELETE(av);
 
-               for (i = 0, j = av_tindex(av); i < j; ++i, --j) {
+               for (i = 0, j = av_top_index(av); i < j; ++i, --j) {
                    SV *begin, *end;
 
                    if (can_preserve) {
index 5e4a423..7faa1a9 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -3640,7 +3640,7 @@ PP(pp_multideref)
                             IV len;
                             if (!defer)
                                 DIE(aTHX_ PL_no_aelem, elem);
-                            len = av_tindex(av);
+                            len = av_top_index(av);
                             /* Resolve a negative index that falls within
                              * the array.  Leave it negative it if falls
                              * outside the array.  */
@@ -5392,7 +5392,7 @@ PP(pp_aelem)
            IV len;
            if (!defer)
                DIE(aTHX_ PL_no_aelem, elem);
-           len = av_tindex(av);
+           len = av_top_index(av);
            /* Resolve a negative index that falls within the array.  Leave
               it negative it if falls outside the array.  */
            if (elem < 0 && len + elem >= 0)
index 29f455e..e763c0a 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -10476,7 +10476,7 @@ S_setup_eval_state(pTHX_ regmatch_info *const reginfo)
             /* this regexp is also owned by the new PL_reg_curpm, which
                will try to free it.  */
             av_push(PL_regex_padav, repointer);
-            PL_reg_curpm->op_pmoffset = av_tindex(PL_regex_padav);
+            PL_reg_curpm->op_pmoffset = av_top_index(PL_regex_padav);
             PL_regex_pad = AvARRAY(PL_regex_padav);
         }
 #endif
index 9b032bd..6797b9f 100644 (file)
@@ -789,7 +789,7 @@ XS(XS_PerlIO_get_layers)
             AV* const av = PerlIO_get_layers(aTHX_ input ?
                                        IoIFP(io) : IoOFP(io));
             SSize_t i;
-            const SSize_t last = av_tindex(av);
+            const SSize_t last = av_top_index(av);
             SSize_t nitem = 0;
             
             for (i = last; i >= 0; i -= 3) {