Simplify code a bit by returning immediately from _check_metaclass_compatibility...
Dave Rolsky [Sat, 14 Aug 2010 16:35:32 +0000 (18:35 +0200)]
lib/Class/MOP/Class.pm

index c206649..d383e20 100644 (file)
@@ -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 );
         }
     }
 }