authorgravatar for bratishkaerik@landless-city.netEric Joldasov <bratishkaerik@landless-city.net> 2024-09-15 21:35:18+05:00
committergravatar for bratishkaerik@landless-city.netEric Joldasov <bratishkaerik@landless-city.net> 2025-01-20 14:29:01+05:00
log5bbf3f55616cf4b021fecacd41b73bfea8ab953f
tree91f65a71cd4f6cb0c0f462866aaabe3cda067cb0
parentd5db02728ce3ff3ba74a3e3f9050c3ea9ed34752
signaturelock-open Commit is signed but in an unrecognized format.

std.fs.path.joinSepMaybeZ: replace while-loops with for-loops

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>

1 files changed, 2 insertions(+), 6 deletions(-)

lib/std/fs/path.zig+2-6
...@@ -90,9 +90,7 @@ fn joinSepMaybeZ(allocator: Allocator, separator: u8, comptime sepPredicate: fn...@@ -90,9 +90,7 @@ fn joinSepMaybeZ(allocator: Allocator, separator: u8, comptime sepPredicate: fn
90 var sum: usize = paths[first_path_index].len;90 var sum: usize = paths[first_path_index].len;
91 var prev_path = paths[first_path_index];91 var prev_path = paths[first_path_index];
92 assert(prev_path.len > 0);92 assert(prev_path.len > 0);
93 var i: usize = first_path_index + 1;93 for (paths[first_path_index + 1 ..]) |this_path| {
94 while (i < paths.len) : (i += 1) {
95 const this_path = paths[i];
96 if (this_path.len == 0) continue;94 if (this_path.len == 0) continue;
97 const prev_sep = sepPredicate(prev_path[prev_path.len - 1]);95 const prev_sep = sepPredicate(prev_path[prev_path.len - 1]);
98 const this_sep = sepPredicate(this_path[0]);96 const this_sep = sepPredicate(this_path[0]);
...@@ -112,9 +110,7 @@ fn joinSepMaybeZ(allocator: Allocator, separator: u8, comptime sepPredicate: fn...@@ -112,9 +110,7 @@ fn joinSepMaybeZ(allocator: Allocator, separator: u8, comptime sepPredicate: fn
112 var buf_index: usize = paths[first_path_index].len;110 var buf_index: usize = paths[first_path_index].len;
113 var prev_path = paths[first_path_index];111 var prev_path = paths[first_path_index];
114 assert(prev_path.len > 0);112 assert(prev_path.len > 0);
115 var i: usize = first_path_index + 1;113 for (paths[first_path_index + 1 ..]) |this_path| {
116 while (i < paths.len) : (i += 1) {
117 const this_path = paths[i];
118 if (this_path.len == 0) continue;114 if (this_path.len == 0) continue;
119 const prev_sep = sepPredicate(prev_path[prev_path.len - 1]);115 const prev_sep = sepPredicate(prev_path[prev_path.len - 1]);
120 const this_sep = sepPredicate(this_path[0]);116 const this_sep = sepPredicate(this_path[0]);