Skip to content

Commit

Permalink
the stash can be a little faster
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 11, 2016
1 parent 2d98637 commit 06abe8c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/Mojo/Util.pm
Expand Up @@ -431,15 +431,14 @@ sub _stash {
my ($name, $object) = (shift, shift);

# Hash
my $dict = $object->{$name} ||= {};
return $dict unless @_;
return $object->{$name} ||= {} unless @_;

# Get
return $dict->{$_[0]} unless @_ > 1 || ref $_[0];
return $object->{$name}{$_[0]} unless @_ > 1 || ref $_[0];

# Set
my $values = ref $_[0] ? $_[0] : {@_};
@$dict{keys %$values} = values %$values;
@{$object->{$name}}{keys %$values} = values %$values;

return $object;
}
Expand Down

0 comments on commit 06abe8c

Please sign in to comment.