From: Shawn M Moore Date: Wed, 3 Dec 2008 03:58:01 +0000 (+0000) Subject: Use fewer assignments when doing a coercion in the constructor X-Git-Tag: 0.19~136^2~68 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7bf66a9ba9b5cb3c3b10bdd24e27c1170674088a;p=gitmo%2FMouse.git Use fewer assignments when doing a coercion in the constructor --- diff --git a/lib/Mouse/Meta/Method/Constructor.pm b/lib/Mouse/Meta/Method/Constructor.pm index c0cf03e..103cd31 100644 --- a/lib/Mouse/Meta/Method/Constructor.pm +++ b/lib/Mouse/Meta/Method/Constructor.pm @@ -40,10 +40,11 @@ sub _generate_processattrs { my $part1 = do { my @code; - push @code, "my \$value = \$args->{'$from'};"; - if ($attr->should_coerce) { - push @code, "\$value = \$attr->coerce_constraint( \$value );"; + push @code, "my \$value = \$attr->coerce_constraint( \$args->{'$from'});"; + } + else { + push @code, "my \$value = \$args->{'$from'};"; } if ($attr->has_type_constraint) {