Some simplifications and corrections suggested by nothingmuch++
Shawn M Moore [Sun, 27 Jan 2008 15:24:04 +0000 (15:24 +0000)]
lib/Class/MOP/Instance.pm

index 458b084..a9612a9 100644 (file)
@@ -124,16 +124,12 @@ sub rebless_instance_structure {
 
 sub get_all_slot_values {
     my ($self, $instance) = @_;
-    my $class = $self->associated_metaclass;
-    my %map;
 
-    for my $attr ($class->compute_all_applicable_attributes) {
-        my $name = $attr->name;
-        $map{$name} = $self->get_slot_value($instance, $name)
-            if $self->is_slot_initialized($instance, $name);
-    }
-
-    return \%map;
+    return +{
+        map { $_->name => $_->get_value($instance) }
+            grep { $_->has_value($instance) }
+                $self->associated_metaclass->compute_all_applicable_attributes
+    };
 }
 
 # inlinable operation snippets