From: gfx Date: Sun, 12 Sep 2010 06:01:06 +0000 (+0900) Subject: Tweaks for method modifiers X-Git-Tag: 0.69~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d686eec5998e18a15198c9f333954bd6761e8258;p=gitmo%2FMouse.git Tweaks for method modifiers --- diff --git a/benchmarks/modifiers.pl b/benchmarks/modifiers.pl index aa041c6..fa6b440 100644 --- a/benchmarks/modifiers.pl +++ b/benchmarks/modifiers.pl @@ -11,10 +11,6 @@ use Class::Method::Modifiers (); printf "Perl %vd on $Config{archname}\n", $^V; my @mods = qw(Moose Mouse Class::Method::Modifiers); -if(eval{ require Class::Method::Modifiers::Fast }){ - push @mods, 'Class::Method::Modifiers::Fast'; -} - foreach my $class(@mods){ print "$class ", $class->VERSION, "\n"; } diff --git a/lib/Mouse/Meta/Class.pm b/lib/Mouse/Meta/Class.pm index 7ac4c83..daa9dc1 100644 --- a/lib/Mouse/Meta/Class.pm +++ b/lib/Mouse/Meta/Class.pm @@ -281,19 +281,16 @@ sub _install_modifier { my $modifier_table = $self->{modifiers}{$name}; if(!$modifier_table){ - my(@before, @after, $cache); - - $cache = $original; - - my $around_only = ($type eq 'around'); - + my(@before, @after, @around); + my $cache = $original; my $modified = sub { - if($around_only) { + if(@before) { + for my $c (@before) { $c->(@_) } + } + unless(@after) { return $cache->(@_); } - for my $c (@before) { $c->(@_) } - if(wantarray){ # list context my @rval = $cache->(@_); @@ -319,8 +316,7 @@ sub _install_modifier { before => \@before, after => \@after, - around => \my @around, - around_only => \$around_only, + around => \@around, cache => \$cache, # cache for around modifiers }; @@ -329,11 +325,9 @@ sub _install_modifier { } if($type eq 'before'){ - ${$modifier_table->{around_only}} = 0; unshift @{$modifier_table->{before}}, $code; } elsif($type eq 'after'){ - ${$modifier_table->{around_only}} = 0; push @{$modifier_table->{after}}, $code; } else{ # around