From: Yuval Kogman Date: Sun, 10 Aug 2008 13:40:42 +0000 (+0000) Subject: use package cache flag in Moose::Meta::Role X-Git-Tag: 0_55_01~46 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6b76efa4370026610e290364ad9c47676380955c;p=gitmo%2FMoose.git use package cache flag in Moose::Meta::Role --- diff --git a/lib/Moose/Meta/Role.pm b/lib/Moose/Meta/Role.pm index 640cb84..82c7972 100644 --- a/lib/Moose/Meta/Role.pm +++ b/lib/Moose/Meta/Role.pm @@ -285,7 +285,16 @@ sub method_metaclass { 'Moose::Meta::Role::Method' } sub get_method_map { my $self = shift; - my $map = {}; + + my $current = Class::MOP::check_package_cache_flag($self->name); + + if (defined $self->{'_package_cache_flag'} && $self->{'_package_cache_flag'} == $current) { + return $self->{'methods'} ||= {}; + } + + $self->{_package_cache_flag} = $current; + + my $map = $self->{'methods'} ||= {}; my $role_name = $self->name; my $method_metaclass = $self->method_metaclass; @@ -295,6 +304,10 @@ sub get_method_map { foreach my $symbol (keys %all_code) { my $code = $all_code{$symbol}; + next if exists $map->{$symbol} && + defined $map->{$symbol} && + $map->{$symbol}->body == $code; + my ($pkg, $name) = Class::MOP::get_code_info($code); if ($pkg->can('meta') @@ -305,7 +318,7 @@ sub get_method_map { # loudly (in the case of Curses.pm) so we # just be a little overly cautious here. # - SL - && eval { no warnings; blessed($pkg->meta) } + && eval { no warnings; blessed($pkg->meta) } # FIXME calls meta && $pkg->meta->isa('Moose::Meta::Role')) { my $role = $pkg->meta->name; next unless $self->does_role($role);