Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Both var and contvar are fine for $_ deletion.
  • Loading branch information
jnthn committed Apr 11, 2014
1 parent 452c89d commit c27ec40
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/Perl6/Optimizer.nqp
Expand Up @@ -473,18 +473,21 @@ my class BlockVarOptimizer {
%kill<$!> := 1;
}
}
if nqp::existskey(%!decls, '$_') && %!decls<$_>.decl eq 'var' {
if !nqp::existskey(%!usages_flat, '$_') && !nqp::existskey(%!usages_inner, '$_') {
if !@!getlexouter_binds {
%kill<$_> := 1;
}
elsif nqp::elems(@!getlexouter_binds) == 1 {
my $glob := @!getlexouter_binds[0];
if $glob[0].name eq '$_' && $glob[1][0].value eq '$_' {
$glob.op('null');
$glob.shift(); $glob.shift();
if nqp::existskey(%!decls, '$_') {
my str $decl := %!decls<$_>.decl;
if $decl eq 'var' || $decl eq 'contvar' {
if !nqp::existskey(%!usages_flat, '$_') && !nqp::existskey(%!usages_inner, '$_') {
if !@!getlexouter_binds {
%kill<$_> := 1;
}
elsif nqp::elems(@!getlexouter_binds) == 1 {
my $glob := @!getlexouter_binds[0];
if $glob[0].name eq '$_' && $glob[1][0].value eq '$_' {
$glob.op('null');
$glob.shift(); $glob.shift();
%kill<$_> := 1;
}
}
}
}
}
Expand Down

0 comments on commit c27ec40

Please sign in to comment.