This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: Simplify a couple of expressions
authorKarl Williamson <khw@cpan.org>
Wed, 28 Dec 2016 02:20:08 +0000 (19:20 -0700)
committerKarl Williamson <khw@cpan.org>
Tue, 3 Jan 2017 04:46:41 +0000 (21:46 -0700)
By storing an intermediate result in a temporary, the final expression
is clearer.

toke.c

diff --git a/toke.c b/toke.c
index a0e3643..0b9b8fc 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -3734,8 +3734,9 @@ S_scan_const(pTHX_ char *start)
 
                            /* See Note on sizing above.  (NOTE: SvCUR() is not
                             * set correctly here). */
+                            const STRLEN extra = len + (send - e) + 1;
                            const STRLEN off = d - SvPVX_const(sv);
-                           d = off + SvGROW(sv, off + len + (STRLEN)(send - s) + 1);
+                           d = off + SvGROW(sv, off + extra);
                        }
                        Copy(str, d, len, char);
                        d += len;
@@ -3836,8 +3837,9 @@ S_scan_const(pTHX_ char *start)
                /* encoded value larger than old, may need extra space (NOTE:
                 * SvCUR() is not set correctly here).   See Note on sizing
                 * above.  */
+                const STRLEN extra = need + (send - s) + 1;
                const STRLEN off = d - SvPVX_const(sv);
-               d = SvGROW(sv, off + need + (STRLEN)(send - s) + 1) + off;
+               d = off + SvGROW(sv, off + extra);
            }
            s += len;