From: Peter Rabbitson Date: Wed, 29 Jun 2016 22:40:15 +0000 (+0200) Subject: Add hash-based ISA lookup to RV of describe_class_methods X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2603b49536d45448ac98cd8aa7c7393867cb0db2;p=dbsrgits%2FDBIx-Class.git Add hash-based ISA lookup to RV of describe_class_methods --- diff --git a/lib/DBIx/Class/_Util.pm b/lib/DBIx/Class/_Util.pm index 1c9c4b0..37d4ad7 100644 --- a/lib/DBIx/Class/_Util.pm +++ b/lib/DBIx/Class/_Util.pm @@ -734,13 +734,11 @@ sub modver_gt_or_eq_and_lt ($$$) { unless ( ($slot->{cumulative_gen}||0) == $my_gen ) { - # remove ourselves from ISA - shift @full_ISA; - # reset %$slot = ( class => $class, - isa => [ + isa => { map { $_ => 1 } @full_ISA }, + linear_isa => [ @{ $mro_recursor_stack->{cache}{$stack_cache_key}{linear_isa} } [ 1 .. $#{$mro_recursor_stack->{cache}{$stack_cache_key}{linear_isa}} ] ], @@ -751,6 +749,9 @@ sub modver_gt_or_eq_and_lt ($$$) { cumulative_gen => $my_gen, ); + # remove ourselves from ISA + shift @full_ISA; + # ensure the cache is populated for the parents, code below can then # efficiently operate over the query_cache directly describe_class_methods($_) for reverse @full_ISA; diff --git a/xt/extra/internals/attributes.t b/xt/extra/internals/attributes.t index 2717b00..5169d23 100644 --- a/xt/extra/internals/attributes.t +++ b/xt/extra/internals/attributes.t @@ -286,13 +286,18 @@ sub add_more_attrs { # check that describe_class_methods returns the right stuff # ( on the simpler class ) - my $expected_AttrTest_ISA = [qw( + my $expected_AttrTest_linear_ISA = [qw( DBICTest::SomeParentClass DBICTest::SomeGrandParentClass DBICTest::AnotherParentClass DBIx::Class::MethodAttributes )]; + my $expected_AttrTest_full_ISA = { map { $_ => 1 } ( + qw( UEBERVERSAL UNIVERSAL DBICTest::AttrTest ), + @$expected_AttrTest_linear_ISA, + )}; + my $expected_desc = { class => "DBICTest::AttrTest", @@ -302,12 +307,8 @@ sub add_more_attrs { require Math::BigInt; my $gen = Math::BigInt->new(0); - $gen += DBIx::Class::_Util::get_real_pkg_gen($_) for ( - 'UEBERVERSAL', - 'UNIVERSAL', - 'DBICTest::AttrTest', - @$expected_AttrTest_ISA, - ); + $gen += DBIx::Class::_Util::get_real_pkg_gen($_) + for keys %$expected_AttrTest_full_ISA; $gen; }, @@ -315,7 +316,8 @@ sub add_more_attrs { type => 'c3', is_c3 => 1, }, - isa => $expected_AttrTest_ISA, + linear_isa => $expected_AttrTest_linear_ISA, + isa => $expected_AttrTest_full_ISA, methods => { FETCH_CODE_ATTRIBUTES => [ { @@ -444,7 +446,7 @@ sub add_more_attrs { # due to DFS the last 2 entries of ISA and the VALID_DBIC_CODE_ATTRIBUTE # sourcing-list will change places splice @$_, -2, 2, @{$_}[-1, -2] - for $V_D_C_A_stack, $expected_AttrTest_ISA; + for $V_D_C_A_stack, $expected_AttrTest_linear_ISA; is_deeply ( # work around taint, see TODO below @@ -498,7 +500,8 @@ sub add_more_attrs { class => 'UEBERVERSAL', mro => { is_c3 => 0, type => 'dfs' }, - isa => [], + isa => { UEBERVERSAL => 1 }, + linear_isa => [], methods => { ueber => $expected_desc->{methods}{ueber} },