From: Matt S Trout Date: Mon, 6 Mar 2006 22:50:18 +0000 (+0000) Subject: C3 loading speedup X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e6efde04063f1374151f9f76ef1e7c23a045e91e;p=dbsrgits%2FDBIx-Class-Historic.git C3 loading speedup --- diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 4e3e62c..65c235c 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -196,17 +196,27 @@ sub load_classes { $comps_for{$class} = \@comp; } - foreach my $prefix (keys %comps_for) { - foreach my $comp (@{$comps_for{$prefix}||[]}) { - my $comp_class = "${prefix}::${comp}"; - eval "use $comp_class"; # If it fails, assume the user fixed it - if ($@) { - die $@ unless $@ =~ /Can't locate/; + my @to_register; + { + no warnings qw/redefine/; + local *Class::C3::reinitialize = sub { }; + foreach my $prefix (keys %comps_for) { + foreach my $comp (@{$comps_for{$prefix}||[]}) { + my $comp_class = "${prefix}::${comp}"; + eval "use $comp_class"; # If it fails, assume the user fixed it + if ($@) { + die $@ unless $@ =~ /Can't locate/; + } + push(@to_register, [ $comp, $comp_class ]); } - $class->register_class($comp => $comp_class); - # if $class->can('result_source_instance'); } } + Class::C3->reinitialize; + + foreach my $to (@to_register) { + $class->register_class(@$to); + # if $class->can('result_source_instance'); + } } =head2 compose_connection