The complexity of caching pkg_gen is in fact making things slower
[p5sagit/Class-Accessor-Grouped.git] / lib / Class / Accessor / Grouped.pm
index c568f6b..5f1c441 100644 (file)
@@ -73,12 +73,14 @@ sub _mk_group_accessors {
   $maker = $self->can($maker) unless ref $maker;
 
   for (@fields) {
-    if( $_ eq 'DESTROY' ) {
-      Carp::carp("Having a data accessor named DESTROY in '$class' is unwise.");
-    }
 
     my ($name, $field) = (ref $_) ? (@$_) : ($_, $_);
 
+    for (qw/DESTROY AUTOLOAD CLONE/) {
+      Carp::carp("Having a data accessor named '$name' in '$class' is unwise.")
+        if $name eq $_;
+    }
+
     my $alias = "_${name}_accessor";
 
     for my $meth ($name, $alias) {
@@ -280,16 +282,8 @@ sub get_inherited {
   my $cag_slot = '::__cag_'. $_[1];
   return ${$class.$cag_slot} if defined(${$class.$cag_slot});
 
-  # we need to be smarter about recalculation, as @ISA (thus supers) can very well change in-flight
-  my $cur_gen = mro::get_pkg_gen ($class);
-  if ( $cur_gen != ${$class.'::__cag_pkg_gen__'} ) {
-    @{$class.'::__cag_supers__'} = $_[0]->get_super_paths;
-    ${$class.'::__cag_pkg_gen__'} = $cur_gen;
-  }
-
-  for (@{$class.'::__cag_supers__'}) {
-    return ${$_.$cag_slot} if defined(${$_.$cag_slot});
-  };
+  do { return ${$_.$cag_slot} if defined(${$_.$cag_slot}) }
+    for $_[0]->get_super_paths;
 
   return undef;
 }