This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_formline: FF_LINEGLOB: always SvCUR_set
authorDavid Mitchell <davem@iabyn.com>
Sun, 29 May 2011 12:03:54 +0000 (13:03 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sun, 29 May 2011 19:21:53 +0000 (20:21 +0100)
The code currently does SvCUR_set(PL_formtarget,...) in three out of four
of the condition branches. Since it's harmless to do it also for the
fourth, remove the three individual SvCUR_set()s and replace with a single
unconditional one.

pp_ctl.c

index 7b037da..0225685 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -919,24 +919,20 @@ PP(pp_formline)
 
            {
                U8 *tmp = NULL;
+
+               SvCUR_set(PL_formtarget,
+                         t - SvPVX_const(PL_formtarget));
+
                if (targ_is_utf8 && !item_is_utf8) {
                    source = tmp = bytes_to_utf8(source, &to_copy);
-                   SvCUR_set(PL_formtarget,
-                             t - SvPVX_const(PL_formtarget));
                } else {
                    if (item_is_utf8 && !targ_is_utf8) {
                        /* Upgrade targ to UTF8, and then we reduce it to
-                          a problem we have a simple solution for.  */
-                       SvCUR_set(PL_formtarget,
-                                 t - SvPVX_const(PL_formtarget));
-                       targ_is_utf8 = TRUE;
-                       /* Don't need get magic.  */
+                          a problem we have a simple solution for.
+                          Don't need get magic.  */
                        sv_utf8_upgrade_nomg(PL_formtarget);
-                   } else {
-                       SvCUR_set(PL_formtarget,
-                                 t - SvPVX_const(PL_formtarget));
+                       targ_is_utf8 = TRUE;
                    }
-
                    /* Easy. They agree.  */
                    assert (item_is_utf8 == targ_is_utf8);
                }