From: Jesse Luehrs Date: Fri, 12 Nov 2010 02:46:04 +0000 (-0600) Subject: speed up has_method a little bit, hopefully X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5018df3eea5b6b41aa78a0d999903887c2873eca;p=gitmo%2FClass-MOP.git speed up has_method a little bit, hopefully --- diff --git a/lib/Class/MOP/Mixin/HasMethods.pm b/lib/Class/MOP/Mixin/HasMethods.pm index d08d273..e343d20 100644 --- a/lib/Class/MOP/Mixin/HasMethods.pm +++ b/lib/Class/MOP/Mixin/HasMethods.pm @@ -103,7 +103,10 @@ sub has_method { ( defined $method_name && length $method_name ) || confess "You must define a method name"; - return defined( $self->_get_maybe_raw_method($method_name) ); + my $method = $self->_get_maybe_raw_method($method_name) + or return; + + return defined($self->_method_map->{$method_name} = $method); } sub get_method { @@ -128,7 +131,7 @@ sub _get_maybe_raw_method { my ( $self, $method_name ) = @_; my $map_entry = $self->_method_map->{$method_name}; - return $map_entry if blessed $map_entry; + return $map_entry if defined $map_entry; my $code = $self->get_package_symbol( {