authorgravatar for luke.champine@gmail.comlukechampine <luke.champine@gmail.com> 2019-10-29 13:16:57-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-10-29 21:32:02-04:00
log48b5dc051622350acb18bd726cd59627e02c5efc
tree54532c9473730113cfef88ea476965fdd318de34
parent4f594527c02985272d61c198d7c5aafa7d777e50

inline path separator loop


1 files changed, 1 insertions(+), 21 deletions(-)

lib/std/fs/path.zig+1-21
...@@ -253,27 +253,7 @@ pub fn windowsParsePath(path: []const u8) WindowsPath {...@@ -253,27 +253,7 @@ pub fn windowsParsePath(path: []const u8) WindowsPath {
253 return relative_path;253 return relative_path;
254 }254 }
255255
256 // TODO when I combined these together with `inline for` the compiler crashed256 inline for ("/\\") |this_sep| {
257 {
258 const this_sep = '/';
259 const two_sep = [_]u8{ this_sep, this_sep };
260 if (mem.startsWith(u8, path, two_sep)) {
261 if (path[2] == this_sep) {
262 return relative_path;
263 }
264
265 var it = mem.tokenize(path, [_]u8{this_sep});
266 _ = (it.next() orelse return relative_path);
267 _ = (it.next() orelse return relative_path);
268 return WindowsPath{
269 .is_abs = isAbsoluteWindows(path),
270 .kind = WindowsPath.Kind.NetworkShare,
271 .disk_designator = path[0..it.index],
272 };
273 }
274 }
275 {
276 const this_sep = '\\';
277 const two_sep = [_]u8{ this_sep, this_sep };257 const two_sep = [_]u8{ this_sep, this_sep };
278 if (mem.startsWith(u8, path, two_sep)) {258 if (mem.startsWith(u8, path, two_sep)) {
279 if (path[2] == this_sep) {259 if (path[2] == this_sep) {