Skip to content

Commit

Permalink
Make IO::Spec::Win32.tmpdir about 1.8x as fast
Browse files Browse the repository at this point in the history
- use for loop with return instead of first()
  • Loading branch information
lizmat committed May 23, 2020
1 parent ecd06c9 commit 6d427d4
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/core.c/IO/Spec/Win32.pm6
Expand Up @@ -39,22 +39,15 @@ my class IO::Spec::Win32 is IO::Spec::Unix {

method tmpdir {
my $ENV := %*ENV;
my $io;
first( {
for $ENV<TMPDIR>, $ENV<TEMP>, $ENV<TMP>,
'SYS:/temp', 'C:\system\temp', 'C:/temp', '/tmp', '/' {
if .defined {
$io = .IO;
$io.d && $io.rwx;
my $io := IO::Path.new($_);
return $io if $io.d && $io.rwx
}
},
$ENV<TMPDIR>,
$ENV<TEMP>,
$ENV<TMP>,
'SYS:/temp',
'C:\system\temp',
'C:/temp',
'/tmp',
'/',
) ?? $io !! IO::Path.new(".");
}

IO::Path.new(".")
}

method path {
Expand Down

0 comments on commit 6d427d4

Please sign in to comment.