Skip to content

Commit

Permalink
small optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 18, 2012
1 parent e774ea0 commit e12093c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -6,6 +6,7 @@
- Added squish method to Mojo::ByteStream.
- Added squish function to Mojo::Util.
- Improved documentation.
- Improved tests.
- Fixed json_has method in Test::Mojo.

3.31 2012-08-15
Expand Down
29 changes: 13 additions & 16 deletions lib/Mojolicious/Controller.pm
Expand Up @@ -372,8 +372,7 @@ sub session {
my $self = shift;

# Hash
my $stash = $self->stash;
my $session = $stash->{'mojo.session'} ||= {};
my $session = $self->stash->{'mojo.session'} ||= {};
return $session unless @_;

# Get
Expand Down Expand Up @@ -509,20 +508,18 @@ sub _fallbacks {
my ($self, $options, $template, $inline) = @_;

# Mode specific template
unless ($self->render($options)) {

# Template
$options->{template} = $template;
unless ($self->render($options)) {

# Inline template
my $stash = $self->stash;
return unless $stash->{format} eq 'html';
delete $stash->{$_} for qw(extends layout);
delete $options->{template};
return $self->render(%$options, inline => $inline, handler => 'ep');
}
}
return 1 if $self->render($options);

# Template
$options->{template} = $template;
return 1 if $self->render($options);

# Inline template
my $stash = $self->stash;
return unless $stash->{format} eq 'html';
delete $stash->{$_} for qw(extends layout);
delete $options->{template};
return $self->render(%$options, inline => $inline, handler => 'ep');
}

1;
Expand Down
3 changes: 1 addition & 2 deletions t/mojo/websocket.t
Expand Up @@ -76,8 +76,7 @@ websocket '/early_start' => sub {
$self->on(
message => sub {
my ($self, $message) = @_;
$self->send("${message}test2");
$self->finish;
$self->send("${message}test2")->finish;
}
);
};
Expand Down

0 comments on commit e12093c

Please sign in to comment.