From: Dave Rolsky Date: Mon, 28 Jul 2008 02:00:16 +0000 (+0000) Subject: It's a bit less gross (maybe) to just return a new version of @_ X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=be139e1c10402507a81cc6f9938e5625b8f1694b;p=gitmo%2FMoose.git It's a bit less gross (maybe) to just return a new version of @_ rather than returning a value and modifying @_ in place via a reference. --- diff --git a/lib/Moose.pm b/lib/Moose.pm index 27e204e..0322c7d 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -192,17 +192,15 @@ use Moose::Util (); ); sub _strip_traits { - my $at = shift; + my $idx = first_index { $_ eq '-traits' } @_; - my $idx = first_index { $_ eq '-traits' } @{ $at }; + return unless $idx && $#_ >= $idx + 1; - return unless $idx && $#{ $at } >= $idx + 1; + my $traits = $_[ $idx + 1 ]; - my $traits = $at->[ $idx + 1 ]; + splice @_, $idx, 2; - splice @{ $at }, $idx, 2; - - return $traits; + return ( $traits, @_ ) } # 1 extra level because it's called by import so there's a layer of indirection @@ -228,7 +226,8 @@ use Moose::Util (); } sub import { - my $traits = _strip_traits(\@_); + my $traits; + ( $traits, @_ ) = _strip_traits(@_); $CALLER = _get_caller(@_);