This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Perl_sv_vcatpvfn_flags: simplify v/asterisk code
authorDavid Mitchell <davem@iabyn.com>
Fri, 26 May 2017 21:26:58 +0000 (22:26 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 7 Jun 2017 08:11:04 +0000 (09:11 +0100)
The previous commit's rearrangement of the v and * code now allows us to:
1) eliminate the 'vectorarg' bool variable, which is set but no longer
   used;
2) join two adjacent "if (asterisk)" and "if (!asterisk)" blocks into a
   single if/else.

sv.c

diff --git a/sv.c b/sv.c
index 1355485..bf3f300 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -11882,7 +11882,6 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
        IV iv            = 0;         /* ditto for signed types */
 
        bool vectorize   = FALSE;     /* has      "%v..."    */
-       bool vectorarg   = FALSE;     /* has      "%*v..."   */
        SV *vecsv        = NULL;      /* the cur arg for %v  */
        bool vec_utf8    = FALSE;     /* SvUTF8(vecsv)       */
        const U8 *vecstr = NULL;      /* SvPVX(vecsv)        */
@@ -11999,7 +11998,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
            q++;
            if (vectorize)
                goto unknown;
-           if ((vectorarg = asterisk)) {
+           if (asterisk) { /* *v, *NNN$v */
                evix = ewix;
                ewix = 0;
                asterisk = FALSE;
@@ -12029,16 +12028,6 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
            goto tryasterisk;
        }
 
-       if (!asterisk)
-       {
-           if(*q == '0') {
-               fill = TRUE;
-                q++;
-            }
-           width = expect_number(&q);
-       }
-
-
        if (asterisk) {
             int i;
            if (args)
@@ -12049,6 +12038,14 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
            left |= (i < 0);
            width = (i < 0) ? -i : i;
        }
+       else {
+           if(*q == '0') {
+               fill = TRUE;
+                q++;
+            }
+           width = expect_number(&q);
+       }
+
       gotwidth:
 
        /* PRECISION */