This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Perl_sv_vcatpvfn_flags: reduce scope of 'have' var
authorDavid Mitchell <davem@iabyn.com>
Tue, 9 May 2017 13:48:59 +0000 (14:48 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 7 Jun 2017 08:11:00 +0000 (09:11 +0100)
Just declare this var in the small block where its needed, rather than
being in scope for 500+ lines.

Should be no functional changes.

sv.c

diff --git a/sv.c b/sv.c
index 14b8384..70a268f 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -11627,7 +11627,6 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
 #  define FV_ISFINITE(x) Perl_isfinite((NV)(x))
 #endif
         NV nv;
-       STRLEN have;
        STRLEN float_need; /* what PL_efloatsize needs to become */
        STRLEN gap;
        const char *dotstr = ".";
@@ -13041,14 +13040,17 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
            }
        }
 
-        /* signed value that's wrapped? */
-        assert(elen  <= ((~(STRLEN)0) >> 1));
-       have = esignlen + zeros + elen;
-       if (have < zeros)
-           croak_memory_wrap();
 
         {
-            STRLEN need = (have > width ? have : width);
+            STRLEN need, have;
+
+            /* signed value that's wrapped? */
+            assert(elen  <= ((~(STRLEN)0) >> 1));
+            have = esignlen + zeros + elen;
+            if (have < zeros)
+                croak_memory_wrap();
+
+            need = (have > width ? have : width);
             gap = need - have;
 
             if (need >= (((STRLEN)~0) - SvCUR(sv) - dotstrlen - 1))