Skip to content

Commit

Permalink
small optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 18, 2012
1 parent 97306d3 commit 1655599
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/Mojo/Template.pm
Expand Up @@ -95,16 +95,15 @@ sub build {
}

# Escape helper
my $escape = "no warnings \'redefine\';sub _escape {";
$escape .= q/return $_[0] if ref $_[0] eq 'Mojo::ByteStream';/;
$escape .= "no warnings 'uninitialized';" . $self->escape;
$escape .= "} use Mojo::Base -strict;";
my $escape = "no warnings 'redefine'; sub _escape {";
$escape .= q{return $_[0] if ref $_[0] eq 'Mojo::ByteStream';};
$escape .= "no warnings 'uninitialized'; @{[$self->escape]} }";

# Wrap lines
my $first = $lines[0] ||= '';
$lines[0] = 'package ' . $self->namespace . ";$escape";
$lines[0] .= "sub { my \$_M = ''; " . $self->prepend . "; do { $first";
$lines[-1] .= $self->append . "; \$_M; } };";
$lines[0] = "package @{[$self->namespace]}; $escape use Mojo::Base -strict;";
$lines[0] .= "sub { my \$_M = ''; @{[$self->prepend]}; do { $first";
$lines[-1] .= "@{[$self->append]}; \$_M } };";

# Code
my $code = join "\n", @lines;
Expand Down

0 comments on commit 1655599

Please sign in to comment.