- $link = substr $after, 0, $trim;
-# $offset += $context + 1;
- $self->[$offset + ++$penalty] =~ /^\Q$link/
- while $offset + $penalty < $#$self;
+ $link = substr $self->[$after], 0, $trim;
+ # advance lookbehind offset on the next page
+ $penalty = 0;
+ for ($offset .. $#$self) {
+ last if $self->[$offset + $shrunk] =~ /^\Q$link/;
+ $shrunk++;
+ }