Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Speedup display of regex match
Only subst in the couple hundred chars around the current match position.

If the target is hundreds or thousands of lines long then this is always going to be a lot faster. Right now the impact is colossal for target strings of more than a dozen typical text file lines.
  • Loading branch information
raiph committed Apr 30, 2014
1 parent 30c8475 commit 6d6fb6b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/Debugger/UI/CommandLine.pm
Expand Up @@ -131,8 +131,10 @@ my class SourceFile {
if $cur ~~ Cursor {
my $pos = $cur.pos;
my $str = $cur.target;
my $before = $str.substr(0, $pos).subst(/\n/, '\n', :g).subst(/\t/, '\t', :g);
my $after = $str.substr($pos).subst(/\n/, '\n', :g).subst(/\t/, '\t', :g);
my $bfrom = [max] 0, $pos - 77;
my $blen = [min] 77, $pos;
my $before = $str.substr($bfrom, $blen).subst(/\n/, '\n', :g).subst(/\t/, '\t', :g);
my $after = $str.substr($pos, 144).subst(/\n/, '\n', :g).subst(/\t/, '\t', :g);
if $before.chars + $after.chars > 77 {
if $after.chars > 43 {
$after = $after.substr(0, 40) ~ '...';
Expand Down

0 comments on commit 6d6fb6b

Please sign in to comment.