-
-
Save anonymous/893bba4201eb6dc3d34a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Changes b/Changes | |
index 3c32a45..77c48f0 100644 | |
--- a/Changes | |
+++ b/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. | |
diff --git a/lib/Mojo/Template.pm b/lib/Mojo/Template.pm | |
index ed84f8b..b4dc590 100644 | |
--- a/lib/Mojo/Template.pm | |
+++ b/lib/Mojo/Template.pm | |
@@ -223,7 +223,12 @@ sub parse { | |
@capture_token = (); | |
} | |
} | |
- push @$tree, \@token; | |
+ | |
+ # Optimize successive text lines | |
+ my $p = $tree->[-1]; | |
+ push @$tree, \@token and next | |
+ if !$p || grep { @$_ != 2 || $_->[0] ne 'text' } $p, \@token; | |
+ $p->[1] .= $token[1]; | |
} | |
return $self; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment