Skip to content

Commit

Permalink
improved Mojolicious::Renderer performance further
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 17, 2012
1 parent 3cf4916 commit b67364a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,8 +1,9 @@
This file documents the revision history for Perl extension Mojolicious.

2.63 2012-03-17 00:00:00
- Improved Mojolicious::Renderer performance significantly.
- Improved Mojolicious::Renderer performance.
- Improved documentation.
- Fixed bug that slowed down Mojolicious::Renderer.

2.62 2012-03-17 00:00:00
- Deprecated Mojolicious::Renderer->default_template_class in favor
Expand Down
20 changes: 15 additions & 5 deletions lib/Mojolicious/Renderer.pm
Expand Up @@ -222,13 +222,23 @@ sub _detect_handler {

# Templates
return unless my $file = $self->template_name($options);
$file = quotemeta $file;
my $templates = $self->{templates}
||= [map { @{Mojo::Home->new($_)->list_files} } @{$self->paths}];
/^$file\.(\w+)$/ and return $1 for @$templates;
unless ($self->{templates}) {
my $list = [map { @{Mojo::Home->new($_)->list_files} } @{$self->paths}];
for my $file (sort @$list) {
next unless $file =~ s/\.(\w+)$//;
$self->{templates}->{$file} ||= $1;
}
}
return $self->{templates}->{$file} if defined $self->{templates}->{$file};

# DATA templates
/^$file\.(\w+)$/ and return $1 for keys %{$self->_data_templates};
unless ($self->{data}) {
for my $file (sort keys %{$self->_data_templates}) {
next unless $file =~ s/\.(\w+)$//;
$self->{data}->{$file} ||= $1;
}
}
return $self->{data}->{$file} if defined $self->{data}->{$file};

return;
}
Expand Down

0 comments on commit b67364a

Please sign in to comment.