From 48b5dc051622350acb18bd726cd59627e02c5efc Mon Sep 17 00:00:00 2001 From: lukechampine Date: Tue, 29 Oct 2019 13:16:57 -0400 Subject: [PATCH] inline path separator loop --- lib/std/fs/path.zig | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/lib/std/fs/path.zig b/lib/std/fs/path.zig index f337e1df9a..1c9e3e100b 100644 --- a/lib/std/fs/path.zig +++ b/lib/std/fs/path.zig @@ -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) {