From: Peter Rabbitson Date: Wed, 8 Dec 2010 09:49:27 +0000 (+0000) Subject: Fix undefer tracker to play nice with Module::Unload (DBICSL) X-Git-Tag: v0.10001~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2d392af1722569c5e7be42d3b0987fd72e070b5c;p=p5sagit%2FClass-Accessor-Grouped.git Fix undefer tracker to play nice with Module::Unload (DBICSL) --- diff --git a/Changes b/Changes index 37014ce..3fdb9a6 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,6 @@ Revision history for Class::Accessor::Grouped. + - Fix spurious method re-invocation warnings after Class::Unload 0.10000 Sat Nov 27 17:51:04 2010 - Fix perl 5.6 failures diff --git a/lib/Class/Accessor/Grouped.pm b/lib/Class/Accessor/Grouped.pm index fa83694..b0b75ee 100644 --- a/lib/Class/Accessor/Grouped.pm +++ b/lib/Class/Accessor/Grouped.pm @@ -646,24 +646,25 @@ $gen_accessor = sub { die sprintf( "Class::XSAccessor requested but not available:\n%s\n", __CAG_NO_CXSA ) if __CAG_NO_CXSA; - my %deferred_calls_seen; - return sub { my $current_class = Scalar::Util::blessed( $_[0] ) || $_[0]; if (__CAG_TRACK_UNDEFER_FAIL) { + my $deferred_calls_seen = do { + no strict 'refs'; + \%{"${current_class}::__cag_deferred_xs_shim_invocations"} + }; my @cframe = caller(0); - if ($deferred_calls_seen{$current_class}{$cframe[3]}) { + if (my $already_seen = $deferred_calls_seen->{$cframe[3]}) { Carp::carp ( "Deferred version of method $cframe[3] invoked more than once (originally " - . "invoked at $deferred_calls_seen{$current_class}{$cframe[3]}). This is a strong " - . 'indication your code has cached the original ->can derived method coderef, ' - . 'and is using it instead of the proper method re-lookup, causing performance ' - . 'regressions' + . "invoked at $already_seen). This is a strong indication your code has " + . 'cached the original ->can derived method coderef, and is using it instead ' + . 'of the proper method re-lookup, causing performance regressions' ); } else { - $deferred_calls_seen{$current_class}{$cframe[3]} = "$cframe[1] line $cframe[2]"; + $deferred_calls_seen->{$cframe[3]} = "$cframe[1] line $cframe[2]"; } }