From: gfx Date: Sun, 20 Dec 2009 07:07:53 +0000 (+0900) Subject: Lazy loading of Class::C3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=61188096b68393d96286e5579bfd2129cdfd6fb7;p=gitmo%2FMouse.git Lazy loading of Class::C3 --- diff --git a/lib/Mouse/Util.pm b/lib/Mouse/Util.pm index e94ca84..ddad56d 100644 --- a/lib/Mouse/Util.pm +++ b/lib/Mouse/Util.pm @@ -138,8 +138,6 @@ BEGIN { }; # ^^^^^ CODE TAKEN FROM MRO::COMPAT ^^^^^ - eval{ require Class::C3 }; - # MRO::Compat::__get_linear_isa has no prototype, so # we define a prototyped version for compatibility with core's # See also MRO::Compat::__get_linear_isa. @@ -151,9 +149,16 @@ BEGIN { our %MRO; $type = exists $MRO{$classname} ? 'c3' : 'dfs'; } - return $type eq 'c3' - ? [calculateMRO($classname)] - : $_get_linear_isa_dfs->($classname); + if($type eq 'c3'){ + require Class::C3; + return [ calculateMRO($classname) ]; + } + elsif($type eq 'dfs'){ + return $_get_linear_isa_dfs->($classname); + } + else{ + Carp::croak("Unknown mro type '$type'"); + } }; }