[Catalyst-commits] r8577 - Catalyst-Runtime/5.80/trunk/lib/Catalyst
matthewt at dev.catalyst.perl.org
matthewt at dev.catalyst.perl.org
Tue Oct 28 00:33:06 GMT 2008
Author: matthewt
Date: 2008-10-28 00:33:06 +0000 (Tue, 28 Oct 2008)
New Revision: 8577
Modified:
Catalyst-Runtime/5.80/trunk/lib/Catalyst/ClassData.pm
Log:
inline symbol table tweaking in ClassData
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/ClassData.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/ClassData.pm 2008-10-27 14:39:28 UTC (rev 8576)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/ClassData.pm 2008-10-28 00:33:06 UTC (rev 8577)
@@ -12,18 +12,27 @@
my $slot = '$'.$attribute;
my $accessor = sub {
my $meta = $_[0]->meta;
+ my $pkg = ref $_[0] || $_[0];
if(@_ > 1){
$meta->namespace->{$attribute} = \$_[1];
return $_[1];
}
- if( $meta->has_package_symbol($slot) ){
- return ${ $meta->get_package_symbol($slot) };
+ # tighter version of
+ # if ( $meta->has_package_symbol($slot) ) {
+ # return ${ $meta->get_package_symbol($slot) };
+ # }
+ no strict 'refs';
+ my $v = *{"${pkg}::${attribute}"}{SCALAR};
+ if (defined ${$v}) {
+ return ${$v};
} else {
foreach my $super ( $meta->linearized_isa ) {
- my $super_meta = Moose::Meta::Class->initialize($super);
- if( $super_meta->has_package_symbol($slot) ){
- return ${ $super_meta->get_package_symbol($slot) };
+ # tighter version of same after
+ # my $super_meta = Moose::Meta::Class->initialize($super);
+ my $v = *{"${super}::${attribute}"}{SCALAR};
+ if (defined ${$v}) {
+ return ${$v};
}
}
}
More information about the Catalyst-commits
mailing list