Lazy loading of Class::C3
[gitmo/Mouse.git] / lib / Mouse / Util.pm
index 107f700..ddad56d 100644 (file)
@@ -38,7 +38,7 @@ BEGIN{
     # Because Mouse::Util is loaded first in all the Mouse sub-modules,
     # XS loader is placed here, not in Mouse.pm.
 
-    our $VERSION = '0.44';
+    our $VERSION = '0.45';
 
     my $xs = !(exists $INC{'Mouse/PurePerl.pm'} || $ENV{MOUSE_PUREPERL});
 
@@ -54,7 +54,7 @@ BEGIN{
             Mouse::Util->import({ into => 'Mouse::Meta::Method::Destructor::XS'  }, ':meta');
             Mouse::Util->import({ into => 'Mouse::Meta::Method::Accessor::XS'    }, ':meta');
             return 1;
-        };
+        } || 0;
         #warn $@ if $@;
     }
 
@@ -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);\r
+            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'");
+            }
         };
     }
 
@@ -350,7 +355,7 @@ Mouse::Util - Features, with or without their dependencies
 
 =head1 VERSION
 
-This document describes Mouse version 0.44
+This document describes Mouse version 0.45
 
 =head1 IMPLEMENTATIONS FOR