This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: Avoid extra sv_setpv for foo <newline> =>
authorFather Chrysostomos <sprout@cpan.org>
Thu, 4 Sep 2014 19:52:39 +0000 (12:52 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 4 Sep 2014 20:39:49 +0000 (13:39 -0700)
commite3a09cfbb80ddcd428e9868bcf0a818a8c8cae0c
tree2b5cccb2584bd364f10adc7cda15ef74e456bc6d
parente74036d119d0e671765ea56042a585158a686d2c
toke.c: Avoid extra sv_setpv for foo <newline> =>

When parsing something like

    time
       =>

if there is a global override, the parser transforms ‘time’ into
‘CORE::GLOBAL::time’ before it looks at the next line to see if there
is a fat arrow.

If it finds a fat arrow, it has to set the name back to ‘time’.

After finding a fat arrow on the line following a bareword, it was
setting the name to what appears in the program source, even when
there was no global override.  We can skip that most of the time.

All that I said about global overrides applies to ‘our’ subs, too.
‘foo’ gets transformed into ‘ThatPackage::foo’ and needs to be changed
back.  I added a test, to make sure that is not accidentally broken.

I took the liberty of changing ((SVOP*)pl_yylval.opval)->op_sv to sv
at the same time, to make the code more readable.
t/op/lexsub.t
toke.c