Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
small optimization
  • Loading branch information
kraih committed Jun 17, 2013
1 parent d844857 commit 6c353e0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/Mojolicious/Plugins.pm
Expand Up @@ -14,13 +14,13 @@ sub emit_hook {
sub emit_chain {
my ($self, $name, @args) = @_;

my $wrapper = sub { };
my $wrapper;
for my $cb (reverse @{$self->subscribers($name)}) {
my $next = $wrapper;
$wrapper = sub { $cb->($next, @args) };
}

return $wrapper->();
!$wrapper ? return : return $wrapper->();
}

sub emit_hook_reverse {
Expand Down
1 change: 0 additions & 1 deletion t/mojolicious/app.t
Expand Up @@ -116,7 +116,6 @@ is $custom, 3, 'hook has been emitted again';
$t->app->hook(
'custom_chain' => sub {
my ($next, $num) = @_;
$next->();
return $num;
}
);
Expand Down

0 comments on commit 6c353e0

Please sign in to comment.