This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
rmv a sv_2mortal and unused var in toke.c:Perl_yyerror_pvn
authorDaniel Dragan <bulk88@hotmail.com>
Sat, 27 Oct 2012 05:44:13 +0000 (01:44 -0400)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 28 Oct 2012 09:04:58 +0000 (02:04 -0700)
newSVpvn_flags is capable of mortalizing already, use that, is_utf8 is used
only once, waste of an auto var stack slot to calculate it so early,
instead create the flags arg to newSVpvn_flags at the point of usage.
flags param of yyerror_pvn will always be on the C stack.

toke.c

diff --git a/toke.c b/toke.c
index 45468b3..e4c1f80 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -11041,7 +11041,6 @@ Perl_yyerror_pvn(pTHX_ const char *const s, STRLEN len, U32 flags)
     SV *msg;
     SV * const where_sv = newSVpvs_flags("", SVs_TEMP);
     int yychar  = PL_parser->yychar;
-    U32 is_utf8 = flags & SVf_UTF8;
 
     PERL_ARGS_ASSERT_YYERROR_PVN;
 
@@ -11102,7 +11101,7 @@ Perl_yyerror_pvn(pTHX_ const char *const s, STRLEN len, U32 flags)
        else
            Perl_sv_catpvf(aTHX_ where_sv, "\\%03o", yychar & 255);
     }
-    msg = sv_2mortal(newSVpvn_flags(s, len, is_utf8));
+    msg = newSVpvn_flags(s, len, (flags & SVf_UTF8) | SVs_TEMP);
     Perl_sv_catpvf(aTHX_ msg, " at %s line %"IVdf", ",
         OutCopFILE(PL_curcop), (IV)CopLINE(PL_curcop));
     if (context)