Skip to content

Commit

Permalink
[io grant] Make IO::Spec::Cygwin.is-absolute 21x faster
Browse files Browse the repository at this point in the history
  • Loading branch information
zoffixznet committed May 14, 2017
1 parent 7c8f8d3 commit 48cf0e6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/core/IO/Spec/Cygwin.pm
Expand Up @@ -19,8 +19,15 @@ my class IO::Spec::Cygwin is IO::Spec::Unix {
$result.subst(/ <[\\\/]> ** 2..*/, '/');
}

method is-absolute ($file) {
so $file ~~ / ^ [<[A..Z a..z]> ':']? <[\\/]>/; # C:/test
method is-absolute ($path) {
nqp::p6bool(
nqp::iseq_i(($_ := nqp::ord($path)), 92) # /^ 「\」 /
|| nqp::iseq_i($_, 47) # /^ 「/」 /
|| (nqp::eqat($path, ':', 1) # /^ <[A..Z a..z]> ':' [ 「\」 | 「/」 ] /
&& ( (nqp::isge_i($_, 65) && nqp::isle_i($_, 90)) # drive letter
|| (nqp::isge_i($_, 97) && nqp::isle_i($_, 122)))
&& ( nqp::iseq_i(($_ := nqp::ordat($path, 2)), 92) # slash
|| nqp::iseq_i($_, 47))))
}

method tmpdir {
Expand Down

0 comments on commit 48cf0e6

Please sign in to comment.