Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Optimization for negated character classes
  • Loading branch information
sorear committed Sep 13, 2010
1 parent 1705097 commit 0c65460
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Optimizer/RxSimple.pm
Expand Up @@ -67,6 +67,27 @@ sub RxOp::Sequence::rxsimp { my ($self, $cut) = @_;
push @kids, $k;
}
}
NEGCC: {
last NEGCC unless @kids;
my @cond = @kids;
my $fin = pop @cond;
for (@cond) {
last NEGCC unless $_->isa('RxOp::NotBefore') &&
$_->zyg->[0]->isa('RxOp::CClassElem');
$_ = $_->zyg->[0]->cc;
}
if ($fin->isa('RxOp::CClassElem')) {
$fin = $fin->cc;
} elsif ($fin->isa('RxOp::Any')) {
$fin = $CClass::Full;
} else {
last NEGCC;
}
for (@cond) {
$fin = $fin->minus($_);
}
return RxOp::CClassElem->new(cc => $fin);
}
(@kids == 1) ? $kids[0] : RxOp::Sequence->new(zyg => \@kids);
}

Expand Down

0 comments on commit 0c65460

Please sign in to comment.