Skip to content

Commit

Permalink
remove remaining usage of List::MoreUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
Grinnz authored and wchristian committed Jul 1, 2017
1 parent 39e65ac commit 0cd5905
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 31 deletions.
1 change: 0 additions & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ eval {
requires 'Clone' => '0.30';
requires 'File::Spec' => win32() ? '3.2701' : '0.84';
requires 'IO::String' => '1.07';
requires 'List::MoreUtils' => '0.16';
requires 'List::Util' => '1.33';
requires 'Params::Util' => '1.00';

Expand Down
26 changes: 13 additions & 13 deletions lib/PPI/Element.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use strict;
use Clone ();
use Scalar::Util qw{refaddr};
use Params::Util qw{_INSTANCE _ARRAY};
use List::MoreUtils ();
use List::Util ();
use PPI::Util ();
use PPI::Node ();
use PPI::Singletons '%_PARENT';
Expand Down Expand Up @@ -259,9 +259,9 @@ sub next_sibling {
my $parent = $_PARENT{refaddr $self} or return '';
my $key = refaddr $self;
my $elements = $parent->{children};
my $position = List::MoreUtils::firstidx {
refaddr $_ == $key
} @$elements;
my $position = List::Util::first {
refaddr $elements->[$_] == $key
} 0..$#$elements;
$elements->[$position + 1] || '';
}

Expand All @@ -282,9 +282,9 @@ sub snext_sibling {
my $parent = $_PARENT{refaddr $self} or return '';
my $key = refaddr $self;
my $elements = $parent->{children};
my $position = List::MoreUtils::firstidx {
refaddr $_ == $key
} @$elements;
my $position = List::Util::first {
refaddr $elements->[$_] == $key
} 0..$#$elements;
while ( defined(my $it = $elements->[++$position]) ) {
return $it if $it->significant;
}
Expand All @@ -307,9 +307,9 @@ sub previous_sibling {
my $parent = $_PARENT{refaddr $self} or return '';
my $key = refaddr $self;
my $elements = $parent->{children};
my $position = List::MoreUtils::firstidx {
refaddr $_ == $key
} @$elements;
my $position = List::Util::first {
refaddr $elements->[$_] == $key
} 0..$#$elements;
$position and $elements->[$position - 1] or '';
}

Expand All @@ -330,9 +330,9 @@ sub sprevious_sibling {
my $parent = $_PARENT{refaddr $self} or return '';
my $key = refaddr $self;
my $elements = $parent->{children};
my $position = List::MoreUtils::firstidx {
refaddr $_ == $key
} @$elements;
my $position = List::Util::first {
refaddr $elements->[$_] == $key
} 0..$#$elements;
while ( $position-- and defined(my $it = $elements->[$position]) ) {
return $it if $it->significant;
}
Expand Down
1 change: 0 additions & 1 deletion lib/PPI/Lexer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ For more unusual tasks, by all means forge onwards.
use strict;
use Scalar::Util ();
use Params::Util qw{_STRING _INSTANCE};
use List::MoreUtils ();
use PPI ();
use PPI::Exception ();
use PPI::Singletons '%_PARENT';
Expand Down
30 changes: 15 additions & 15 deletions lib/PPI/Node.pm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ L<PPI::Element> objects also apply to C<PPI::Node> objects.
use strict;
use Carp ();
use Scalar::Util qw{refaddr};
use List::MoreUtils ();
use List::Util ();
use Params::Util qw{_INSTANCE _CLASS _CODELIKE _NUMBER};
use PPI::Element ();
use PPI::Singletons '%_PARENT';
Expand Down Expand Up @@ -510,10 +510,10 @@ sub remove_child {

# Find the position of the child
my $key = refaddr $child;
my $p = List::MoreUtils::firstidx {
refaddr $_ == $key
} @{$self->{children}};
return undef if $p == -1;
my $p = List::Util::first {
refaddr $self->{children}[$_] == $key
} 0..$#{$self->{children}};
return undef unless defined $p;

# Splice it out, and remove the child's parent entry
splice( @{$self->{children}}, $p, 1 );
Expand Down Expand Up @@ -692,16 +692,16 @@ sub DESTROY {
# Find the position of a child
sub __position {
my $key = refaddr $_[1];
List::MoreUtils::firstidx { refaddr $_ == $key } @{$_[0]->{children}};
List::Util::first { refaddr $_[0]{children}[$_] == $key } 0..$#{$_[0]{children}};
}

# Insert one or more elements before a child
sub __insert_before_child {
my $self = shift;
my $key = refaddr shift;
my $p = List::MoreUtils::firstidx {
refaddr $_ == $key
} @{$self->{children}};
my $p = List::Util::first {
refaddr $self->{children}[$_] == $key
} 0..$#{$self->{children}};
foreach ( @_ ) {
Scalar::Util::weaken(
$_PARENT{refaddr $_} = $self
Expand All @@ -715,9 +715,9 @@ sub __insert_before_child {
sub __insert_after_child {
my $self = shift;
my $key = refaddr shift;
my $p = List::MoreUtils::firstidx {
refaddr $_ == $key
} @{$self->{children}};
my $p = List::Util::first {
refaddr $self->{children}[$_] == $key
} 0..$#{$self->{children}};
foreach ( @_ ) {
Scalar::Util::weaken(
$_PARENT{refaddr $_} = $self
Expand All @@ -731,9 +731,9 @@ sub __insert_after_child {
sub __replace_child {
my $self = shift;
my $key = refaddr shift;
my $p = List::MoreUtils::firstidx {
refaddr $_ == $key
} @{$self->{children}};
my $p = List::Util::first {
refaddr $self->{children}[$_] == $key
} 0..$#{$self->{children}};
foreach ( @_ ) {
Scalar::Util::weaken(
$_PARENT{refaddr $_} = $self
Expand Down
2 changes: 1 addition & 1 deletion t/lib/PPI/Test/Object.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package PPI::Test::Object;
use warnings;
use strict;

use List::MoreUtils 'any';
use List::Util 1.33 'any';
use Params::Util qw{_INSTANCE};
use PPI::Dumper;
use Test::More;
Expand Down

0 comments on commit 0cd5905

Please sign in to comment.