From: Tokuhiro Matsuno Date: Thu, 4 Dec 2008 23:17:23 +0000 (+0000) Subject: micro optimization X-Git-Tag: 0.19~136^2~37 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4a1986d03489bda0b1fbb5803b164f45fa763141;p=gitmo%2FMouse.git micro optimization --- diff --git a/lib/Mouse/Meta/Method/Constructor.pm b/lib/Mouse/Meta/Method/Constructor.pm index 77cced9..c386e3d 100644 --- a/lib/Mouse/Meta/Method/Constructor.pm +++ b/lib/Mouse/Meta/Method/Constructor.pm @@ -41,14 +41,14 @@ sub _generate_processattrs { my @code; if ($attr->should_coerce) { - push @code, "my \$value = \$attr->coerce_constraint( \$args->{'$from'});"; + push @code, "my \$value = \$attrs[$index]->coerce_constraint( \$args->{'$from'});"; } else { push @code, "my \$value = \$args->{'$from'};"; } if ($attr->has_type_constraint) { - push @code, "\$attr->verify_type_constraint( \$value );"; + push @code, "\$attrs[$index]->verify_type_constraint( \$value );"; } push @code, "\$instance->{'$key'} = \$value;"; @@ -58,7 +58,7 @@ sub _generate_processattrs { } if ( $attr->has_trigger ) { - push @code, "\$attr->trigger->( \$instance, \$value, \$attr );"; + push @code, "\$attrs[$index]->trigger->( \$instance, \$value, \$attrs[$index] );"; } join "\n", @code; @@ -75,17 +75,17 @@ sub _generate_processattrs { push @code, "my \$value = "; if ($attr->should_coerce) { - push @code, "\$attr->coerce_constraint("; + push @code, "\$attrs[$index]->coerce_constraint("; } if ($attr->has_builder) { push @code, "\$instance->$builder"; } elsif (ref($default) eq 'CODE') { - push @code, "\$attr->default()->()"; + push @code, "\$attrs[$index]->default()->()"; } else { - push @code, "\$attr->default()"; + push @code, "\$attrs[$index]->default()"; } if ($attr->should_coerce) { @@ -96,7 +96,7 @@ sub _generate_processattrs { } if ($attr->has_type_constraint) { - push @code, "\$attr->verify_type_constraint(\$value);"; + push @code, "\$attrs[$index]->verify_type_constraint(\$value);"; } push @code, "\$instance->{'$key'} = \$value;"; @@ -117,7 +117,6 @@ sub _generate_processattrs { }; my $code = <<"..."; { - my \$attr = \$attrs[$index]; if (exists(\$args->{'$from'})) { $set_value; } else {