Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
use implicit $_ a bit more
  • Loading branch information
kraih committed Oct 6, 2014
1 parent 139ac44 commit c88ba3c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo/Collection.pm
Expand Up @@ -26,7 +26,7 @@ sub DESTROY { }
sub c { __PACKAGE__->new(@_) }

sub compact {
$_[0]->new(grep { defined $_ && (ref $_ || length $_) } @{$_[0]});
$_[0]->new(grep { defined && (ref || length) } @{$_[0]});
}

sub each {
Expand Down
7 changes: 3 additions & 4 deletions lib/Mojo/JSON.pm
Expand Up @@ -68,14 +68,13 @@ sub _catch {
}

sub _decode {
my ($json, $unencoded) = @_;

# Missing input
die "Missing or empty input\n" unless length $json;
die "Missing or empty input\n" unless length(local $_ = shift);

# UTF-8
local $_ = $unencoded ? $json : Mojo::Util::decode 'UTF-8', $json;
die "Input is not UTF-8 encoded\n" unless defined $_;
$_ = Mojo::Util::decode 'UTF-8', $_ unless shift;
die "Input is not UTF-8 encoded\n" unless defined;

# Value
my $value = _decode_value();
Expand Down
2 changes: 1 addition & 1 deletion t/mojo/collection.t
Expand Up @@ -48,7 +48,7 @@ is $collection->first(qr/[1-4]/), 4, 'right result';
is $collection->first(sub { ref $_ eq 'CODE' }), undef, 'no result';
$collection = c();
is $collection->first, undef, 'no result';
is $collection->first(sub { defined $_ }), undef, 'no result';
is $collection->first(sub {defined}), undef, 'no result';

# last
is c(5, 4, 3)->last, 3, 'right result';
Expand Down

0 comments on commit c88ba3c

Please sign in to comment.