Skip to content

Commit

Permalink
merge stash a little faster
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 22, 2014
1 parent e4fb6f5 commit 40b0d93
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions lib/Mojolicious.pm
Expand Up @@ -110,8 +110,7 @@ sub handler {
$stash->{'mojo.secrets'} //= $self->secrets;

# Build default controller
my $defaults = $self->defaults;
@{$stash}{keys %$defaults} = values %$defaults;
%$stash = (%$stash, %{$self->defaults});
my $c
= $self->controller_class->new(app => $self, stash => $stash, tx => $tx);
weaken $c->{$_} for qw(app tx);
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Renderer.pm
Expand Up @@ -79,7 +79,7 @@ sub render {
if my $partial = delete $args->{partial};

# Merge stash and arguments
@{$stash}{keys %$args} = values %$args;
%$stash = (%$stash, %$args);

my $options = {
encoding => $self->encoding,
Expand Down
5 changes: 3 additions & 2 deletions lib/Mojolicious/Routes.pm
Expand Up @@ -33,9 +33,10 @@ sub continue {
return $self->auto_render($c) unless my $field = $stack->[$current];

# Merge captures into stash
my @keys = keys %$field;
my $stash = $c->stash;
@{$stash}{@keys} = @{$stash->{'mojo.captures'}}{@keys} = values %$field;
my $captures = $stash->{'mojo.captures'} //= {};
%$captures = (%$captures, %$field);
%$stash = (%$stash, %$field);

my $continue;
my $last = !$stack->[++$current];
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojolicious/Sessions.pm
Expand Up @@ -37,8 +37,7 @@ sub store {

# Don't reset flash for static files
my $old = delete $session->{flash};
@{$session->{new_flash}}{keys %$old} = values %$old
if $stash->{'mojo.static'};
$session->{new_flash} = $old if $stash->{'mojo.static'};
delete $session->{new_flash} unless keys %{$session->{new_flash}};

# Generate "expires" value from "expiration" if necessary
Expand Down

0 comments on commit 40b0d93

Please sign in to comment.