From: Dave Rolsky Date: Sat, 14 Aug 2010 16:35:32 +0000 (+0200) Subject: Simplify code a bit by returning immediately from _check_metaclass_compatibility... X-Git-Tag: 1.05~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bfeff08aed30cc57ffe4a2f4306f227485635e89;p=gitmo%2FClass-MOP.git Simplify code a bit by returning immediately from _check_metaclass_compatibility when possible --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index c206649..d383e20 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -190,29 +190,31 @@ sub update_package_cache_flag { sub _check_metaclass_compatibility { my $self = shift; - if (my @superclasses = $self->superclasses) { - $self->_fix_metaclass_incompatibility(@superclasses); + my @superclasses = $self->superclasses + or return; + + $self->_fix_metaclass_incompatibility(@superclasses); - my %base_metaclass = $self->_base_metaclasses; + my %base_metaclass = $self->_base_metaclasses; - # this is always okay ... - return if ref($self) eq 'Class::MOP::Class' + # this is always okay ... + return + if ref($self) eq 'Class::MOP::Class' && all { my $meta = $self->$_; - !defined($meta) || $meta eq $base_metaclass{$_} - } keys %base_metaclass; - - for my $superclass (@superclasses) { - $self->_check_class_metaclass_compatibility($superclass); + !defined($meta) || $meta eq $base_metaclass{$_}; } + keys %base_metaclass; - for my $metaclass_type (keys %base_metaclass) { - next unless defined $self->$metaclass_type; - for my $superclass (@superclasses) { - $self->_check_single_metaclass_compatibility( - $metaclass_type, $superclass - ); - } + for my $superclass (@superclasses) { + $self->_check_class_metaclass_compatibility($superclass); + } + + for my $metaclass_type ( keys %base_metaclass ) { + next unless defined $self->$metaclass_type; + for my $superclass (@superclasses) { + $self->_check_single_metaclass_compatibility( $metaclass_type, + $superclass ); } } }