From: Yuval Kogman Date: Sun, 10 Aug 2008 17:42:43 +0000 (+0000) Subject: use associated method map in compute_all_applicable_methods and do it by merging... X-Git-Tag: 0_64_01~54 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c3fba8f4a66349dbe1249447c13ab81ee9048c69;p=gitmo%2FClass-MOP.git use associated method map in compute_all_applicable_methods and do it by merging the hashes instead of by calling get_method all the time --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 63636ba..8630361 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -795,21 +795,15 @@ sub find_method_by_name { sub compute_all_applicable_methods { my $self = shift; - my (@methods, %seen_method); - foreach my $class ($self->linearized_isa) { - # fetch the meta-class ... - my $meta = $self->initialize($class); - foreach my $method_name ($meta->get_method_list()) { - next if exists $seen_method{$method_name}; - $seen_method{$method_name}++; - push @methods => { - name => $method_name, - class => $class, - code => $meta->get_method($method_name) - }; - } - } - return @methods; + my %methods = map { %{ $self->initialize($_)->get_method_map } } reverse $self->linearized_isa; + # return values %methods # TODO make some new API that does this + return map { + { + name => $_->name, + class => $_->associated_metaclass->name, + code => $_, # sigh, overloading + }, + } values %methods; } sub find_all_methods_by_name {