From: Brandon L Black Date: Tue, 1 May 2007 04:35:09 +0000 (+0000) Subject: support XS calc_mdt, improved BEGIN block X-Git-Tag: 0.16~1^2~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=60e37513e8993f22f5e0f8c4595af19ffccdb944;p=gitmo%2FClass-C3.git support XS calc_mdt, improved BEGIN block --- diff --git a/lib/Class/C3.pm b/lib/Class/C3.pm index 30e8736..45babf4 100644 --- a/lib/Class/C3.pm +++ b/lib/Class/C3.pm @@ -12,10 +12,10 @@ our $C3_XS; BEGIN { if($^V < 5.009005) { eval "require Class::C3::XS"; - if($@) { - die $@ if $@ !~ /locate/; - eval "require Algorithm::C3; require Class::C3::next"; - die $@ if $@; + if(my $error = $@) { + die $error if $error !~ /\blocate\b/; + require Algorithm::C3; + require Class::C3::next; } else { $C3_XS = 1; @@ -167,7 +167,7 @@ sub _remove_method_dispatch_tables { return if $C3_IN_CORE; foreach my $class (keys %MRO) { _remove_method_dispatch_table($class); - } + } } sub _remove_method_dispatch_table { @@ -179,7 +179,7 @@ sub _remove_method_dispatch_table { delete ${"${class}::"}{$method} if defined *{"${class}::${method}"}{CODE} && (*{"${class}::${method}"}{CODE} eq $MRO{$class}->{methods}->{$method}->{code}); - } + } } sub calculateMRO { @@ -200,6 +200,8 @@ if($C3_IN_CORE) { elsif($C3_XS) { no warnings 'redefine'; *Class::C3::calculateMRO = \&Class::C3::XS::calculateMRO; + *Class::C3::_calculate_method_dispatch_table + = \&Class::C3::XS::_calculate_method_dispatch_table; } 1;