lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/deps/lib/perl5/PPI/Element.pm in javonet-ruby-sdk-2.4.7 vs lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/deps/lib/perl5/PPI/Element.pm in javonet-ruby-sdk-2.4.8

- old
+ new

@@ -23,16 +23,15 @@ use strict; use Clone 0.30 (); use Scalar::Util qw{refaddr}; use Params::Util qw{_INSTANCE _ARRAY}; -use List::Util (); use PPI::Util (); use PPI::Node (); -use PPI::Singletons '%_PARENT'; +use PPI::Singletons '%_PARENT', '%_POSITION_CACHE'; -our $VERSION = '1.278'; +our $VERSION = '1.279'; our $errstr = ""; use overload 'bool' => \&PPI::Util::TRUE; use overload '""' => 'content'; @@ -257,13 +256,11 @@ sub next_sibling { my $self = shift; my $key = refaddr $self; my $parent = $_PARENT{$key} or return ''; my $elements = $parent->{children}; - my $position = List::Util::first { - refaddr $elements->[$_] == $key - } 0..$#$elements; + my $position = $parent->__position($self); $elements->[$position + 1] || ''; } =pod @@ -280,13 +277,11 @@ sub snext_sibling { my $self = shift; my $key = refaddr $self; my $parent = $_PARENT{$key} or return ''; my $elements = $parent->{children}; - my $position = List::Util::first { - refaddr $elements->[$_] == $key - } 0..$#$elements; + my $position = $parent->__position($self); while ( defined(my $it = $elements->[++$position]) ) { return $it if $it->significant; } ''; } @@ -305,13 +300,11 @@ sub previous_sibling { my $self = shift; my $key = refaddr $self; my $parent = $_PARENT{$key} or return ''; my $elements = $parent->{children}; - my $position = List::Util::first { - refaddr $elements->[$_] == $key - } 0..$#$elements; + my $position = $parent->__position($self); $position and $elements->[$position - 1] or ''; } =pod @@ -328,13 +321,11 @@ sub sprevious_sibling { my $self = shift; my $key = refaddr $self; my $parent = $_PARENT{$key} or return ''; my $elements = $parent->{children}; - my $position = List::Util::first { - refaddr $elements->[$_] == $key - } 0..$#$elements; + my $position = $parent->__position($self); while ( $position-- and defined(my $it = $elements->[$position]) ) { return $it if $it->significant; } ''; } @@ -842,11 +833,13 @@ # Being DESTROYed in this manner, rather than by an explicit # ->delete means our reference count has probably fallen to zero. # Therefore we don't need to remove ourselves from our parent, # just the index ( just in case ). -### XS -> PPI/XS.xs:_PPI_Element__DESTROY 0.900+ -sub DESTROY { delete $_PARENT{refaddr $_[0]} } +sub DESTROY { + delete $_PARENT{refaddr $_[0]}; + delete $_POSITION_CACHE{refaddr $_[0]}; +} # Operator overloads sub __equals { ref $_[1] and refaddr($_[0]) == refaddr($_[1]) } sub __nequals { !__equals(@_) } sub __eq {