-
-
Save anonymous/a0e9be83289c4d796711 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/lib/Mojo/Template.pm b/lib/Mojo/Template.pm | |
index ed84f8b..168900e 100644 | |
--- a/lib/Mojo/Template.pm | |
+++ b/lib/Mojo/Template.pm | |
@@ -226,6 +226,13 @@ sub parse { | |
push @$tree, \@token; | |
} | |
+ # Optimize successive text lines | |
+ my $i = 0; | |
+ while ((my $current = $tree->[$i]) && (my $next = $tree->[$i + 1])) { | |
+ ++$i and next if grep { @$_ != 2 || $_->[0] ne 'text' } $current, $next; | |
+ splice @$tree, $i, 2, ['text', $current->[1] . $next->[1]]; | |
+ } | |
+ | |
return $self; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment