Slightly faster implementation of supers recalc check
[p5sagit/Class-Accessor-Grouped.git] / lib / Class / Accessor / Grouped.pm
index caf7181..df749a9 100644 (file)
@@ -6,7 +6,7 @@ use Class::Inspector ();
 use Scalar::Util ();
 use MRO::Compat;
 
-our $VERSION = '0.07999_01';
+our $VERSION = '0.08002';
 
 =head1 NAME
 
@@ -243,8 +243,6 @@ name passed as an argument.
 =cut
 
 sub get_simple {
-    my ($self, $get) = @_;
-  return $self->{$get};
   return $_[0]->{$_[1]};
 }
 
@@ -303,10 +301,14 @@ sub get_inherited {
     };
 
     no strict 'refs';
+    no warnings qw/uninitialized/;
     return ${$class.'::__cag_'.$_[1]} if defined(${$class.'::__cag_'.$_[1]});
 
-    if (!@{$class.'::__cag_supers'}) {
+    # we need to be smarter about recalculation, as @ISA (thus supers) can very well change in-flight
+    my $pkg_gen = mro::get_pkg_gen ($class);
+    if ( ${$class.'::__cag_pkg_gen'} != $pkg_gen ) {
         @{$class.'::__cag_supers'} = $_[0]->get_super_paths;
+        ${$class.'::__cag_pkg_gen'} = $pkg_gen;
     };
 
     foreach (@{$class.'::__cag_supers'}) {
@@ -363,9 +365,9 @@ Returns: $value
 Gets the value of the specified component class.
 
     __PACKAGE__->mk_group_accessors('component_class' => 'result_class');
-    
+
     $self->result_class->method();
-    
+
     ## same as
     $self->get_component_class('result_class')->method();
 
@@ -390,7 +392,7 @@ it. This method will die if the specified class could not be loaded.
 
     __PACKAGE__->mk_group_accessors('component_class' => 'result_class');
     __PACKAGE__->result_class('MyClass');
-    
+
     $self->result_class->method();
 
 =cut