Skip to content

Commit

Permalink
[io grant] Make IO::Spec::Unix.path consistent and 4.6x faster
Browse files Browse the repository at this point in the history
Return a Seq in all cases, including the empty-list one.
  • Loading branch information
zoffixznet committed May 15, 2017
1 parent 9021a48 commit 0547979
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/core/IO/Spec/Unix.pm
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,13 @@ my class IO::Spec::Unix is IO::Spec {
}

method path {
if %*ENV<PATH> -> $PATH {
$PATH.split( ':' ).map: { $_ || '.' };
}
else {
();
}
(my $p := %*ENV<PATH>) ?? gather {
my int $els = nqp::elems(my $parts := nqp::split(':', $p));
my int $i = -1;
nqp::until(
nqp::iseq_i($els, $i = nqp::add_i($i, 1)),
take nqp::atpos($parts, $i) || '.')
} !! Seq.new: Rakudo::Iterator.Empty
}

method splitpath( $path, :$nofile = False ) {
Expand Down

0 comments on commit 0547979

Please sign in to comment.