From: Shawn M Moore Date: Sat, 28 Mar 2009 22:15:19 +0000 (-0400) Subject: Move class_of into the scope of %METAS to save a method call (since it's X-Git-Tag: 0.80~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=86866fb5fb9013032e271b73504de280c41ee42f;p=gitmo%2FClass-MOP.git Move class_of into the scope of %METAS to save a method call (since it's so hot!) --- diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm index e1c4579..e4962e9 100644 --- a/lib/Class/MOP.pm +++ b/lib/Class/MOP.pm @@ -59,6 +59,12 @@ XSLoader::load( __PACKAGE__, $XS_VERSION ); sub does_metaclass_exist { exists $METAS{$_[0]} && defined $METAS{$_[0]} } sub remove_metaclass_by_name { $METAS{$_[0]} = undef } + # This handles instances as well as class names + sub class_of { + my $class = blessed($_[0]) || $_[0]; + return $METAS{$class}; + } + # NOTE: # We only cache metaclasses, meaning instances of # Class::MOP::Class. We do not cache instance of @@ -136,11 +142,6 @@ sub _is_valid_class_name { return 0; } -sub class_of { - my $class = blessed($_[0]) || $_[0]; - return get_metaclass_by_name($class); -} - ## ---------------------------------------------------------------------------- ## Setting up our environment ... ## ----------------------------------------------------------------------------