From 5bbf3f55616cf4b021fecacd41b73bfea8ab953f Mon Sep 17 00:00:00 2001 From: Eric Joldasov Date: Sun, 15 Sep 2024 21:35:18 +0500 Subject: [PATCH] std.fs.path.joinSepMaybeZ: replace while-loops with for-loops Signed-off-by: Eric Joldasov --- lib/std/fs/path.zig | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/std/fs/path.zig b/lib/std/fs/path.zig index 3376771313..f0f60a2ff1 100644 --- a/lib/std/fs/path.zig +++ b/lib/std/fs/path.zig @@ -90,9 +90,7 @@ fn joinSepMaybeZ(allocator: Allocator, separator: u8, comptime sepPredicate: fn var sum: usize = paths[first_path_index].len; var prev_path = paths[first_path_index]; assert(prev_path.len > 0); - var i: usize = first_path_index + 1; - while (i < paths.len) : (i += 1) { - const this_path = paths[i]; + for (paths[first_path_index + 1 ..]) |this_path| { if (this_path.len == 0) continue; const prev_sep = sepPredicate(prev_path[prev_path.len - 1]); const this_sep = sepPredicate(this_path[0]); @@ -112,9 +110,7 @@ fn joinSepMaybeZ(allocator: Allocator, separator: u8, comptime sepPredicate: fn var buf_index: usize = paths[first_path_index].len; var prev_path = paths[first_path_index]; assert(prev_path.len > 0); - var i: usize = first_path_index + 1; - while (i < paths.len) : (i += 1) { - const this_path = paths[i]; + for (paths[first_path_index + 1 ..]) |this_path| { if (this_path.len == 0) continue; const prev_sep = sepPredicate(prev_path[prev_path.len - 1]); const this_sep = sepPredicate(this_path[0]);