Skip to content

Commit

Permalink
optimize successive text lines in Mojo::Template
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 31, 2014
1 parent ac59188 commit 3d2ed74
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes
@@ -1,5 +1,6 @@

5.36 2014-09-01
- Improved Mojo::Template performance.

5.35 2014-08-30
- Improved monkey_patch to be able to name generated functions.
Expand Down
7 changes: 6 additions & 1 deletion lib/Mojo/Template.pm
Expand Up @@ -223,7 +223,10 @@ sub parse {
@capture_token = ();
}
}
push @$tree, \@token;

# Optimize successive text lines
if (_text($tree->[-1]) && _text(\@token)) { $tree->[-1][1] .= $token[1] }
else { push @$tree, \@token }
}

return $self;
Expand Down Expand Up @@ -252,6 +255,8 @@ sub _line {
return qq{#line @{[shift]} "$name"};
}

sub _text { $_[0] && @{$_[0]} == 2 && $_[0][0] eq 'text' }

sub _trim {
my ($self, $line) = @_;

Expand Down

0 comments on commit 3d2ed74

Please sign in to comment.