return ASAP if the class is already immutable
Karen Etheridge [Wed, 1 Jun 2011 00:36:27 +0000 (00:36 +0000)]
lib/Class/MOP/Class.pm

index a7c3ca3..45dfd46 100644 (file)
@@ -1269,19 +1269,17 @@ sub _immutable_options {
 sub make_immutable {
     my ( $self, @args ) = @_;
 
+    return if not $self->is_mutable;
+
     my ($file, $line) = (caller)[1..2];
-    if ( $self->is_mutable ) {
-        $self->_initialize_immutable(
-            file => $file,
-            line => $line,
-            $self->_immutable_options(@args),
-        );
-        $self->_rebless_as_immutable(@args);
-        return $self;
-    }
-    else {
-        return;
-    }
+
+    $self->_initialize_immutable(
+        file => $file,
+        line => $line,
+        $self->_immutable_options(@args),
+    );
+    $self->_rebless_as_immutable(@args);
+    return $self;
 }
 
 sub make_mutable {