mirror of
https://github.com/ziglang/zig.git
synced 2025-12-24 15:13:08 +00:00
inline path separator loop
This commit is contained in:
parent
4f594527c0
commit
48b5dc0516
@ -253,27 +253,7 @@ pub fn windowsParsePath(path: []const u8) WindowsPath {
|
||||
return relative_path;
|
||||
}
|
||||
|
||||
// TODO when I combined these together with `inline for` the compiler crashed
|
||||
{
|
||||
const this_sep = '/';
|
||||
const two_sep = [_]u8{ this_sep, this_sep };
|
||||
if (mem.startsWith(u8, path, two_sep)) {
|
||||
if (path[2] == this_sep) {
|
||||
return relative_path;
|
||||
}
|
||||
|
||||
var it = mem.tokenize(path, [_]u8{this_sep});
|
||||
_ = (it.next() orelse return relative_path);
|
||||
_ = (it.next() orelse return relative_path);
|
||||
return WindowsPath{
|
||||
.is_abs = isAbsoluteWindows(path),
|
||||
.kind = WindowsPath.Kind.NetworkShare,
|
||||
.disk_designator = path[0..it.index],
|
||||
};
|
||||
}
|
||||
}
|
||||
{
|
||||
const this_sep = '\\';
|
||||
inline for ("/\\") |this_sep| {
|
||||
const two_sep = [_]u8{ this_sep, this_sep };
|
||||
if (mem.startsWith(u8, path, two_sep)) {
|
||||
if (path[2] == this_sep) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user