- Passing "-traits" when loading Moose caused the Moose.pm
exports to be broken. Reported by t0m. (Dave Rolsky)
- Tests for this bug. (t0m)
+
+ * Moose::Util
+ - Change resolve_metaclass alias to use the new
+ load_first_existing_class function. This makes it a lot
+ simpler, and also around 5 times faster. (t0m)
+ - Add caching to resolve_metatrait_alias, which gives an
+ order of magnitude speedup to things which repeatedly call
+ the does method. E.g. MooseX::Storage (t0m)
0.59 Tue October 14, 2008
* Moose
requires 'perl' => '5.008';
requires 'Scalar::Util' => $win32 ? '1.17' : '1.18';
requires 'Carp';
-requires 'Class::MOP' => '0.67';
+requires 'Class::MOP' => '0.68';
requires 'List::MoreUtils';
requires 'Sub::Exporter' => '0.972';
};
}
-sub resolve_metatrait_alias {
- resolve_metaclass_alias( @_, trait => 1 );
+{ my %cache;
+ sub resolve_metatrait_alias {
+ my ( $type, $metaclass_name ) = @_;
+
+ return $cache{$type}{$metaclass_name} if $cache{$type}{$metaclass_name};
+
+ my $class = resolve_metaclass_alias( @_, trait => 1 );
+ $cache{$type}{$metaclass_name} = $class if $class;
+
+ return $class;
+ }
}
sub resolve_metaclass_alias {
my ( $type, $metaclass_name, %options ) = @_;
- if ( my $resolved = eval {
- my $possible_full_name = 'Moose::Meta::' . $type . '::Custom::' . ( $options{trait} ? "Trait::" : "" ) . $metaclass_name;
-
- Class::MOP::load_class($possible_full_name);
+ my $possible_full_name = 'Moose::Meta::' . $type . '::Custom::' . ( $options{trait} ? "Trait::" : "" ) . $metaclass_name;
+ my $loaded_class = Class::MOP::load_first_existing_class($possible_full_name, $metaclass_name);
- $possible_full_name->can('register_implementation')
- ? $possible_full_name->register_implementation
- : $possible_full_name;
- } ) {
- return $resolved;
- } else {
- Class::MOP::load_class($metaclass_name);
- return $metaclass_name;
- }
+ $loaded_class->can('register_implementation')
+ ? $loaded_class->register_implementation
+ : $loaded_class;
}
sub add_method_modifier {