From: tokuhirom Date: Thu, 20 May 2010 01:41:17 +0000 (+0900) Subject: use Data::Util directly, instead of Class::Method::Modifiers::Fast. X-Git-Tag: 0.60~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cabc9331184a2a06167534325b445312b106ac8e;p=gitmo%2FMouse.git use Data::Util directly, instead of Class::Method::Modifiers::Fast. - Class::Method::Modifiers::Fast is minor module on CPAN - It's verbosity layer for this purpose. - Class::Method::Modifiers::Fast->install_modifier is undocumented method. - This patch makes bit faster(i hope). --- diff --git a/Makefile.PL b/Makefile.PL index d7ae893..6a08ac0 100755 --- a/Makefile.PL +++ b/Makefile.PL @@ -34,7 +34,7 @@ if($] < 5.010) { } my %suggests = ( - 'Class::Method::Modifiers::Fast' => 0.041, + 'Data::Util' => 0.55, 'MouseX::AttributeHelpers' => 0.06, ); diff --git a/lib/Mouse/Meta/Class.pm b/lib/Mouse/Meta/Class.pm index 5dd9a4d..663f6ae 100644 --- a/lib/Mouse/Meta/Class.pm +++ b/lib/Mouse/Meta/Class.pm @@ -367,10 +367,10 @@ sub _install_modifier_pp{ sub _install_modifier { my ( $self, $type, $name, $code ) = @_; - # load Class::Method::Modifiers first + # load Data::Util first my $no_cmm_fast = do{ local $@; - eval q{ use Class::Method::Modifiers::Fast 0.041 () }; + eval q{ use Data::Util 0.55 () }; $@; }; @@ -379,13 +379,27 @@ sub _install_modifier { $impl = \&_install_modifier_pp; } else{ - my $install_modifier = Class::Method::Modifiers::Fast->can('install_modifier'); $impl = sub { my ( $self, $type, $name, $code ) = @_; my $into = $self->name; - $install_modifier->($into, $type, $name, $code); - $self->add_method($name => Mouse::Util::get_code_ref($into, $name)); + my $method = Mouse::Util::get_code_ref( $into, $name ); + + if ( !$method || !Data::Util::subroutine_modifier($method) ) { + unless ($method) { + $method = $into->can($name) + or Carp::confess("The method '$name' is not found in the inheritance hierarchy for class $into"); + } + $method = Data::Util::modify_subroutine( $method, + $type => [$code] ); + + $self->add_method($name => $method); + } + else { + Data::Util::subroutine_modifier( $method, $type => $code ); + $self->add_method($name => Mouse::Util::get_code_ref($into, $name)); + } + return; }; }