From: Yuval Kogman Date: Tue, 8 Jan 2008 15:52:38 +0000 (+0000) Subject: Merge 'Moose-moosex_compile_support' into 'trunk' X-Git-Tag: 0_35~34 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=266482596d4d1d6442fd48ec38b031d5ae1c0aa7;p=gitmo%2FMoose.git Merge 'Moose-moosex_compile_support' into 'trunk' r67191@syeeda (orig r3168): nothingmuch | 2007-12-18 06:45:06 +0200 yay --- 266482596d4d1d6442fd48ec38b031d5ae1c0aa7 diff --cc lib/Moose/Meta/Method/Accessor.pm index b669fc7,6d50849..22a3eba --- a/lib/Moose/Meta/Method/Accessor.pm +++ b/lib/Moose/Meta/Method/Accessor.pm @@@ -22,9 -22,12 +22,12 @@@ sub generate_accessor_method_inline my $slot_access = $self->_inline_access($inv, $attr_name); my $value_name = $self->_value_needs_copy ? '$val' : '$_[1]'; + my $type_constraint_obj = $attr->type_constraint; + my $type_constraint_name = $type_constraint_obj && $type_constraint_obj->name; + my $code = 'sub { ' . "\n" . $self->_inline_pre_body(@_) . "\n" - . 'if (scalar(@_) == 2) {' . "\n" + . 'if (scalar(@_) >= 2) {' . "\n" . $self->_inline_copy_value . "\n" . $self->_inline_check_required . "\n" . $self->_inline_check_coercion . "\n" @@@ -40,10 -43,13 +43,14 @@@ # NOTE: # set up the environment my $type_constraint = $attr->type_constraint - ? $attr->type_constraint->_compiled_type_constraint + ? ( + $attr->type_constraint->has_hand_optimized_type_constraint + ? $attr->type_constraint->hand_optimized_type_constraint + : $attr->type_constraint->_compiled_type_constraint + ) : undef; + #warn $code; my $sub = eval $code; confess "Could not create accessor for '$attr_name' because $@ \n code: $code" if $@; return $sub;