Skip to content

Commit

Permalink
XPath shrinker fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislaw Pusep committed May 9, 2012
1 parent 946f33e commit 858405d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/HTML/Linear.pm
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,15 @@ after eof => sub {
my %short;
for my $elem ($self->as_list) {
my @rpath = reverse $elem->as_xpath;
for my $i (0 .. $#rpath) {
my $key = sha256(join '' => @rpath[0 .. $i]);
$short{$key}{offset} = $#rpath - $i;
my $i = 0;
unless ($self->_strict) {
for (; $i <= $#rpath; $i++) {
last if $elem->path->[-1 - $i]->is_groupable;
}
}
for my $j ($i .. $#rpath) {
my $key = sha256(join '' => @rpath[0 .. $j]);
$short{$key}{offset} = $#rpath - $j;
push @{$short{$key}{elem}}, $elem;
++$short{$key}{accumulator}{$elem->as_xpath};
}
Expand Down

0 comments on commit 858405d

Please sign in to comment.