Skip to content

Instantly share code, notes, and snippets.

/static.diff Secret

Created August 31, 2014 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/893bba4201eb6dc3d34a to your computer and use it in GitHub Desktop.
Save anonymous/893bba4201eb6dc3d34a to your computer and use it in GitHub Desktop.
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