From: gfx Date: Sun, 12 Jul 2009 04:31:21 +0000 (+0900) Subject: Cache init_arg() in _generate_slot_initializer() X-Git-Tag: 0.90~25 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2f2329a40a84aae82e9eea1e273bdc088222c16d;p=gitmo%2FClass-MOP.git Cache init_arg() in _generate_slot_initializer() --- diff --git a/lib/Class/MOP/Method/Constructor.pm b/lib/Class/MOP/Method/Constructor.pm index 38b31d5..9a1bf3f 100644 --- a/lib/Class/MOP/Method/Constructor.pm +++ b/lib/Class/MOP/Method/Constructor.pm @@ -174,13 +174,13 @@ sub _generate_slot_initializer { $default = '$instance->'.$attr->builder; } - if ( defined $attr->init_arg ) { + if ( defined(my $init_arg = $attr->init_arg) ) { return ( - 'if(exists $params->{\'' . $attr->init_arg . '\'}){' . "\n" . + 'if(exists $params->{\'' . $init_arg . '\'}){' . "\n" . $self->_meta_instance->inline_set_slot_value( '$instance', $attr->name, - '$params->{\'' . $attr->init_arg . '\'}' ) . "\n" . + '$params->{\'' . $init_arg . '\'}' ) . "\n" . '} ' . (!defined $default ? '' : 'else {' . "\n" . $self->_meta_instance->inline_set_slot_value( '$instance',