From: Peter Rabbitson Date: Sun, 28 Oct 2012 11:01:08 +0000 (+0100) Subject: The complexity of caching pkg_gen is in fact making things slower X-Git-Tag: v0.10007~15 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a3a81175e345c678e7f25eaf150f8495a06e0c26;p=p5sagit%2FClass-Accessor-Grouped.git The complexity of caching pkg_gen is in fact making things slower --- diff --git a/Changes b/Changes index ee5603a..6a39c87 100644 --- a/Changes +++ b/Changes @@ -5,6 +5,7 @@ Revision history for Class::Accessor::Grouped. - Drop minimum perl to 5.6 (from 5.6.2) - Switch all module loading to Module::Runtime and lose dependency on Class::Inspector + - Simplify superclass traversal done by the 'inherited' group type 0.10006 2011-12-30 03:52 (UTC) - Silence warnings resulting from incomplete can() overrides diff --git a/lib/Class/Accessor/Grouped.pm b/lib/Class/Accessor/Grouped.pm index 24b6971..5f1c441 100644 --- a/lib/Class/Accessor/Grouped.pm +++ b/lib/Class/Accessor/Grouped.pm @@ -282,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; }