Created
February 13, 2015 13:24
-
-
Save Tux/4dbf087e5718a1dfee7f to your computer and use it in GitHub Desktop.
return/exit/die after else. YUCK!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IO.pm | |
sub MAKE-ABSOLUTE-PATH($path,$abspath) { | |
if $path.ord == 47 { # 4x faster substr($path,0,1) eq "/" | |
return $path; | |
} | |
elsif substr($path,1,1) eq ':' { # assume C: something | |
if substr($path,2,1) eq "/" { # assume C:/ like prefix | |
return $path; | |
} | |
elsif substr($abspath,0,2) ne substr($path,0,2) { | |
die "Can not set relative dir from different roots"; | |
} | |
else { | |
return $abspath ~ substr($path,2); | |
} | |
} | |
else { # assume relative path | |
return $abspath ~ $path; | |
} | |
} | |
=> | |
sub MAKE-ABSOLUTE-PATH($path,$abspath) { | |
$path.ord == 47 and # 4x faster substr($path,0,1) eq "/" | |
return $path; | |
substr($path,1,1) ne ':' and # C: like prefix? | |
return $abspath ~ $path; # assume relative path | |
# assume C: something | |
substr($path,2,1) eq "/" and # assume C:/ like prefix | |
return $path; | |
substr($abspath,0,2) ne substr($path,0,2) and | |
die "Can not set relative dir from different roots"; | |
return $abspath ~ substr($path,2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment