If we have nothing left to do for the accessor, we can return during set
Shawn M Moore [Sun, 2 Nov 2008 16:39:16 +0000 (16:39 +0000)]
lib/Mouse/Meta/Attribute.pm

index 6530166..5d91002 100644 (file)
@@ -84,7 +84,10 @@ sub generate_accessor {
             }' . "\n"
         }
 
-        $accessor .= $self . '->{'.$key.'} = '. $value .';' . "\n";
+        $accessor .= 'return '
+            if !$attribute->is_weak_ref
+            && !$trigger
+            && !$attribute->should_auto_deref;
 
         if ($attribute->is_weak_ref) {
             $accessor .= 'weaken('.$self.'->{'.$key.'}) if ref('.$self.'->{'.$key.'});' . "\n";