X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FMethod%2FAccessor%2FNative%2FArray%2Fsplice.pm;h=09fbcbec2e22905890e8c9260286923bb4bfd387;hb=f4b86ac0e1fd7ff8a180f2f8332821170db5371e;hp=9108c89483856dd1c7745d750c8e31198c0409d6;hpb=8b9641b857cdd065a68f9b74ad072b1d58fcd4e1;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Method/Accessor/Native/Array/splice.pm b/lib/Moose/Meta/Method/Accessor/Native/Array/splice.pm index 9108c89..09fbcbe 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Array/splice.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Array/splice.pm @@ -3,7 +3,7 @@ package Moose::Meta::Method::Accessor::Native::Array::splice; use strict; use warnings; -our $VERSION = '1.14'; +our $VERSION = '1.16'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -16,6 +16,7 @@ with 'Moose::Meta::Method::Accessor::Native::Array::Writer' => { _inline_process_arguments _inline_check_arguments _inline_optimized_set_new_value + _return_value ) ] }; @@ -41,13 +42,19 @@ sub _potential_value { my ( $self, $slot_access ) = @_; return "( do { my \@potential = \@{ $slot_access };" - . 'defined $len ? ( splice @potential, $idx, $len, @_ ) : ( splice @potential, $idx ); \\@potential } )'; + . '@return = defined $len ? ( splice @potential, $idx, $len, @_ ) : ( splice @potential, $idx ); \\@potential } )'; } sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "defined \$len ? ( splice \@{ $slot_access }, \$idx, \$len, \@_ ) : ( splice \@{ $slot_access }, \$idx )"; + return "\@return = defined \$len ? ( splice \@{ $slot_access }, \$idx, \$len, \@_ ) : ( splice \@{ $slot_access }, \$idx )"; +} + +sub _return_value { + my ($self, $slot_access) = @_; + + return 'return wantarray ? @return : $return[-1]'; } no Moose::Role;