From: Dave Rolsky Date: Tue, 2 Dec 2008 23:28:18 +0000 (+0000) Subject: Avoid calling get_method_map when possible. Instead, we check X-Git-Tag: 0.71_01~29 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c4d8afc3a561ea7febd802f893a390a56d5c3654;p=gitmo%2FClass-MOP.git Avoid calling get_method_map when possible. Instead, we check $self->{methods} directly in several places. --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index b5eda57..e490b57 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -645,15 +645,16 @@ sub add_method { $method->attach_to_class($self); - $self->get_method_map->{$method_name} = $method; + # This used to call get_method_map, which meant we would build all + # the method objects for the class just because we added one + # method. This is hackier, but quicker too. + $self->{methods}{$method_name} = $method; my $full_method_name = ($self->name . '::' . $method_name); $self->add_package_symbol( { sigil => '&', type => 'CODE', name => $method_name }, Class::MOP::subname($full_method_name => $body) ); - - $self->update_package_cache_flag; # still valid, since we just added the method to the map, and if it was invalid before that then get_method_map updated it } { @@ -737,7 +738,7 @@ sub has_method { (defined $method_name && $method_name) || confess "You must define a method name"; - exists $self->get_method_map->{$method_name}; + exists $self->{methods}{$method_name} || exists $self->get_method_map->{$method_name}; } sub get_method { @@ -751,7 +752,7 @@ sub get_method { # will just return undef for me now # return unless $self->has_method($method_name); - return $self->get_method_map->{$method_name}; + return $self->{methods}{$method_name} || $self->get_method_map->{$method_name}; } sub remove_method {