A small optimization to CMOP::Mixin::HasMethods::get_method (from profiling)
[gitmo/Class-MOP.git] / lib / Class / MOP / Mixin / HasMethods.pm
index e8adb87..34a66b4 100644 (file)
@@ -3,7 +3,7 @@ package Class::MOP::Mixin::HasMethods;
 use strict;
 use warnings;
 
-our $VERSION   = '0.98';
+our $VERSION   = '1.04';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
@@ -110,9 +110,8 @@ sub get_method {
     # added via roles or some other such bizareness. Honestly, I don't totally
     # understand this, but returning the entry works, and keeps various MX
     # modules from blowing up. - DR
-    return $map_entry if blessed $map_entry && !$code;
-
-    return $map_entry if blessed $map_entry && $map_entry->body == $code;
+    return $map_entry
+        if blessed $map_entry && ( !$code || $map_entry->body == $code );
 
     unless ($map_entry) {
         return unless $code && $self->_code_is_mine($code);