develooper Front page | perl.perl5.porters | Postings from January 2014

Re: [perl #121077] [PATCH] Optimise 'my $x; my $y' into 'my ($x, $y)'

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
January 27, 2014 15:57
Subject:
Re: [perl #121077] [PATCH] Optimise 'my $x; my $y' into 'my ($x, $y)'
Message ID:
20140127155652.GG27210@iabyn.com
On Mon, Jan 27, 2014 at 10:21:26AM -0500, Matthew Horsfall (alh) wrote:
> On Mon, Jan 27, 2014 at 10:17 AM, Dave Mitchell via RT
> <perlbug-followup@perl.org> wrote:
> > On Mon, Jan 27, 2014 at 09:16:19AM -0500, Matthew Horsfall (alh) wrote:
> >> Actually, Dave, your original padrange optimisation does a lot more
> >> work here to make sure warnings are reported correctly.
> >>
> >> Should that be duplicated here?
> >
> >
> > I'm not sure what you're referring to. Do you mean the code that finds
> > the variable name to report uninitialised vars?
> 
> Oops, I confused your padrange changes and Nicholas' nextstate optimisations.

In that case, the only thing your change would affect is that any warnings
that were generated post your change that affected the first 'my' would appear to come from the later 'my'; e.g.

    my $x;  # a warning here appears to come from line 2 rather than line 1
    my $y;

but I doubt there are any such warnings. The sorts of stuff which might
raise a warning, like attributes, has its own op structure and wouldn't get
optimised anyway.

$ cone -e'my $x: foo; my $y : foo'
1  <0> enter 
2  <;> nextstate(main 40 -e:1) v:{
3  <0> pushmark v
4  <0> pushmark s
5  <$> const[PV "attributes"] sM
6  <$> const[PV "main"] sM
7  <0> padsv[$x:40,42] sRM
8  <1> srefgen sKM/1
9  <$> const[PV "foo"] sM
a  <$> method_named[PV "import"] 
b  <1> entersub[t2] vKS*/TARG
c  <0> padsv[$x:40,42] vM/LVINTRO
d  <@> list vK/128
e  <;> nextstate(main 41 -e:1) v:{
f  <0> pushmark v
g  <0> pushmark s
h  <$> const[PV "attributes"] sM
i  <$> const[PV "main"] sM
j  <0> padsv[$y:41,42] sRM
k  <1> srefgen sKM/1
l  <$> const[PV "foo"] sM
m  <$> method_named[PV "import"] 
n  <1> entersub[t4] vKS*/TARG
o  <0> padsv[$y:41,42] vM/LVINTRO
p  <@> list vK/128
q  <@> leave[1 ref] vKP/REFC


-- 
Red sky at night - gerroff my land!
Red sky at morning - gerroff my land!
    -- old farmers' sayings #14

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About