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 267e376..458e282 100644 (file)
@@ -1257,19 +1257,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 {