From: Tokuhiro Matsuno Date: Fri, 3 Apr 2009 03:12:35 +0000 (+0900) Subject: scope makes slower!mouse's constructer is faster than moose with this commit :) X-Git-Tag: 0.20~22 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=commitdiff_plain;h=53d4053e1f62161dd56e6adf8158eb7df72d1af0 scope makes slower!mouse's constructer is faster than moose with this commit :) --- diff --git a/lib/Mouse/Meta/Method/Constructor.pm b/lib/Mouse/Meta/Method/Constructor.pm index b899026..37e2505 100644 --- a/lib/Mouse/Meta/Method/Constructor.pm +++ b/lib/Mouse/Meta/Method/Constructor.pm @@ -14,7 +14,7 @@ sub generate_constructor_method_inline { my $code = <<"..."; sub { my \$class = shift; - my \$args = $buildargs; + $buildargs; my \$instance = bless {}, \$class; $processattrs; $buildall; @@ -143,20 +143,19 @@ sub _generate_BUILDARGS { my $meta = shift; if ($meta->name->can('BUILDARGS') && $meta->name->can('BUILDARGS') != Mouse::Object->can('BUILDARGS')) { - return '$class->BUILDARGS(@_)'; + return 'my $args = $class->BUILDARGS(@_)'; } return <<'...'; - do { + my $args; if ( scalar @_ == 1 ) { ( ref( $_[0] ) eq 'HASH' ) || Carp::confess "Single parameters to new() must be a HASH ref"; - +{ %{ $_[0] } }; + $args = +{ %{ $_[0] } }; } else { - +{@_}; + $args = +{@_}; } - }; ... }