From 59451cce931230af873a6f789d9178cea70d73ea Mon Sep 17 00:00:00 2001 From: Techatrix Date: Tue, 23 Jun 2026 17:48:27 +0200 Subject: [PATCH] std.Build.Cache: skip over prefixes that are the cwd Any of the added cache prefixes may be the cwd itself. Skip them like the null prefix. --- lib/std/Build/Cache.zig | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/std/Build/Cache.zig b/lib/std/Build/Cache.zig index 9b9e808aaeb72a3423844688c3fb14eb2c100579..cf01a5ff8691d55e26353bdfd3fc446042e4ed6e 100644 --- a/lib/std/Build/Cache.zig +++ b/lib/std/Build/Cache.zig @@ -90,10 +90,8 @@ fn findPrefix(cache: *const Cache, file_path: []const u8) !PrefixedPath { fn findPrefixResolved(cache: *const Cache, resolved_path: []u8) !PrefixedPath { const gpa = cache.gpa; const cwd = cache.cwd; - const prefixes_slice = cache.prefixes(); - var i: u8 = 1; // Start at 1 to skip over checking the null prefix. - while (i < prefixes_slice.len) : (i += 1) { - const p = prefixes_slice[i].path.?; + for (cache.prefixes(), 0..) |prefix, i| { + const p = prefix.path orelse continue; const sub_path = getPrefixSubpath(gpa, cwd, p, resolved_path) catch |err| switch (err) { error.NotASubPath => continue, else => |e| return e, @@ -101,7 +99,7 @@ fn findPrefixResolved(cache: *const Cache, resolved_path: []u8) !PrefixedPath { // Free the resolved path since we're not going to return it gpa.free(resolved_path); return .{ - .prefix = i, + .prefix = @intCast(i), .sub_path = sub_path, }; } -- 2.54.0