From: Graham Knop Date: Tue, 4 Mar 2014 03:04:38 +0000 (-0500) Subject: calculate mro module once X-Git-Tag: v1.003003~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1c93a64319ca3ada66ddceb86bb537e2a7af5893;p=gitmo%2FRole-Tiny.git calculate mro module once --- diff --git a/lib/Role/Tiny.pm b/lib/Role/Tiny.pm index 191c0bd..c5dfe6c 100644 --- a/lib/Role/Tiny.pm +++ b/lib/Role/Tiny.pm @@ -18,6 +18,7 @@ our %COMPOSITE_INFO; BEGIN { *_WORK_AROUND_BROKEN_MODULE_STATE = "$]" < 5.009 ? sub(){1} : sub(){0}; + *_MRO_MODULE = "$]" < 5.010 ? sub(){"MRO/Compat.pm"} : sub(){"mro.pm"}; } sub Role::Tiny::__GUARD__::DESTROY { @@ -143,11 +144,7 @@ sub create_class_with_roles { die "${role} is not a Role::Tiny" unless $me->is_role($role); } - if ($] >= 5.010) { - require mro; - } else { - require MRO::Compat; - } + require(_MRO_MODULE); my $composite_info = $me->_composite_info_for(@roles); my %conflicts = %{$composite_info->{conflicts}}; @@ -432,11 +429,7 @@ sub _install_does { sub does_role { my ($proto, $role) = @_; - if ($] >= 5.010) { - require mro; - } else { - require MRO::Compat; - } + require(_MRO_MODULE); foreach my $class (@{mro::get_linear_isa(ref($proto)||$proto)}) { return 1 if exists $APPLIED_TO{$class}{$role}; }