This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Perl_sv_vcatpvfn_flags: delay vector arg get
authorDavid Mitchell <davem@iabyn.com>
Fri, 26 May 2017 23:00:10 +0000 (00:00 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 7 Jun 2017 08:11:05 +0000 (09:11 +0100)
Move the block of code which retrieves the SV which the %v will iterate
over, from just before the /* SIZE */ block to just after. Since that
block doesn't do anything with args or svargs, this should make no
functional difference - but it will allow the next commit to coalesce
if (x); if (!x); into an single if/else.

Apart from cutting and pasting the code block, no other changes have been
made to it.

sv.c

diff --git a/sv.c b/sv.c
index 4e86988..1c1df1b 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -12101,41 +12101,6 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
            }
        }
 
-       if (vectorize) {
-           if (args) {
-                vecsv = va_arg(*args, SV*);
-                vecstr = (U8*)SvPV_const(vecsv,veclen);
-                vec_utf8 = DO_UTF8(vecsv);
-           }
-           else if (efix ? (efix > 0 && efix <= svmax) : svix < svmax) {
-               vecsv = svargs[efix ? efix-1 : svix++];
-               vecstr = (U8*)SvPV_const(vecsv,veclen);
-               vec_utf8 = DO_UTF8(vecsv);
-
-               /* if this is a version object, we need to convert
-                * back into v-string notation and then let the
-                * vectorize happen normally
-                */
-               if (sv_isobject(vecsv) && sv_derived_from(vecsv, "version")) {
-                   if ( hv_existss(MUTABLE_HV(SvRV(vecsv)), "alpha") ) {
-                       Perl_ck_warner_d(aTHX_ packWARN(WARN_PRINTF),
-                       "vector argument not supported with alpha versions");
-                       goto vdblank;
-                   }
-                   vecsv = sv_newmortal();
-                   scan_vstring((char *)vecstr, (char *)vecstr + veclen,
-                                vecsv);
-                   vecstr = (U8*)SvPV_const(vecsv, veclen);
-                   vec_utf8 = DO_UTF8(vecsv);
-               }
-           }
-           else {
-             vdblank:
-               vecstr = (U8*)"";
-               veclen = 0;
-           }
-       }
-
        /* SIZE */
 
        switch (*q) {
@@ -12215,6 +12180,41 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
            goto string;
        }
 
+       if (vectorize) {
+           if (args) {
+                vecsv = va_arg(*args, SV*);
+                vecstr = (U8*)SvPV_const(vecsv,veclen);
+                vec_utf8 = DO_UTF8(vecsv);
+           }
+           else if (efix ? (efix > 0 && efix <= svmax) : svix < svmax) {
+               vecsv = svargs[efix ? efix-1 : svix++];
+               vecstr = (U8*)SvPV_const(vecsv,veclen);
+               vec_utf8 = DO_UTF8(vecsv);
+
+               /* if this is a version object, we need to convert
+                * back into v-string notation and then let the
+                * vectorize happen normally
+                */
+               if (sv_isobject(vecsv) && sv_derived_from(vecsv, "version")) {
+                   if ( hv_existss(MUTABLE_HV(SvRV(vecsv)), "alpha") ) {
+                       Perl_ck_warner_d(aTHX_ packWARN(WARN_PRINTF),
+                       "vector argument not supported with alpha versions");
+                       goto vdblank;
+                   }
+                   vecsv = sv_newmortal();
+                   scan_vstring((char *)vecstr, (char *)vecstr + veclen,
+                                vecsv);
+                   vecstr = (U8*)SvPV_const(vecsv, veclen);
+                   vec_utf8 = DO_UTF8(vecsv);
+               }
+           }
+           else {
+             vdblank:
+               vecstr = (U8*)"";
+               veclen = 0;
+           }
+       }
+
        if (!vectorize && !args) {
            if (efix) {
                const I32 i = efix-1;