Permalink
Browse files

count lines a little more efficiently

  • Loading branch information...
1 parent 096c98d commit 262c2cda3f2203523b468cc39f2b2f84470bba1d @kraih committed Mar 8, 2014
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/Mojo/Template.pm
@@ -283,11 +283,11 @@ sub _wrap {
};
# Wrap lines
- my $last = scalar split "\n", $code;
+ my $num = () = $code =~ /\n/g;
my $head = $self->_line(1);
$head .= "\npackage @{[$self->namespace]}; use Mojo::Base -strict;";
$code = "$head sub { my \$_M = ''; @{[$self->prepend]}; do { $code\n";
- $code .= $self->_line($last) . "\n@{[$self->append]}; \$_M } };";
+ $code .= $self->_line($num + 1) . "\n@{[$self->append]}; \$_M } };";
warn "-- Code for @{[$self->name]}\n@{[encode 'UTF-8', $code]}\n\n" if DEBUG;
return $code;

0 comments on commit 262c2cd

Please sign in to comment.