Skip to content

Commit

Permalink
Precompute preserve_whitespace and use short-circuit to optimze test
Browse files Browse the repository at this point in the history
  • Loading branch information
mdom committed Jan 25, 2019
1 parent 584e99f commit 03f565b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/App/termpub/Renderer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ sub textnode {
}

my $buffer;
my $left_margin = $self->left_margin;
my $columns = $self->columns;
my $left_margin = $self->left_margin;
my $columns = $self->columns;
my $reduce_whitespace = !$self->preserve_whitespace;

for my $word (@words) {
my $length = length($word);
Expand All @@ -183,10 +184,7 @@ sub textnode {
next;
}

next
if $self->column == 0
&& $word =~ /^\s+$/
&& !$self->preserve_whitespace;
next if $reduce_whitespace && $self->column == 0 && $word =~ /^\s+$/;

if ( $left_margin && $self->column == 0 ) {
my ( $row, $column );
Expand Down

0 comments on commit 03f565b

Please sign in to comment.