From: Shawn M Moore Date: Tue, 3 Feb 2009 21:52:02 +0000 (+0000) Subject: Benchmarking indicates that exists($_[1]) is faster than scalar(@_) >= 2 X-Git-Tag: 0.19~67 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=47cd3181d0a6edc36da5a6dc281cce4fc77c23dc;p=gitmo%2FMouse.git Benchmarking indicates that exists($_[1]) is faster than scalar(@_) >= 2 --- diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index ab72881..dec1300 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -75,7 +75,7 @@ sub generate_accessor { my $accessor = "sub {\n"; if ($attribute->_is_metadata eq 'rw') { - $accessor .= 'if (scalar(@_) >= 2) {' . "\n"; + $accessor .= 'if (exists $_[1]) {' . "\n"; my $value = '$_[1]';