Skip to content

Commit 5bbf3f5

Browse files
committed
std.fs.path.joinSepMaybeZ: replace while-loops with for-loops
Signed-off-by: Eric Joldasov <[email protected]>
1 parent d5db027 commit 5bbf3f5

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/std/fs/path.zig

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ fn joinSepMaybeZ(allocator: Allocator, separator: u8, comptime sepPredicate: fn
9090
var sum: usize = paths[first_path_index].len;
9191
var prev_path = paths[first_path_index];
9292
assert(prev_path.len > 0);
93-
var i: usize = first_path_index + 1;
94-
while (i < paths.len) : (i += 1) {
95-
const this_path = paths[i];
93+
for (paths[first_path_index + 1 ..]) |this_path| {
9694
if (this_path.len == 0) continue;
9795
const prev_sep = sepPredicate(prev_path[prev_path.len - 1]);
9896
const this_sep = sepPredicate(this_path[0]);
@@ -112,9 +110,7 @@ fn joinSepMaybeZ(allocator: Allocator, separator: u8, comptime sepPredicate: fn
112110
var buf_index: usize = paths[first_path_index].len;
113111
var prev_path = paths[first_path_index];
114112
assert(prev_path.len > 0);
115-
var i: usize = first_path_index + 1;
116-
while (i < paths.len) : (i += 1) {
117-
const this_path = paths[i];
113+
for (paths[first_path_index + 1 ..]) |this_path| {
118114
if (this_path.len == 0) continue;
119115
const prev_sep = sepPredicate(prev_path[prev_path.len - 1]);
120116
const this_sep = sepPredicate(this_path[0]);

0 commit comments

Comments
 (0)