authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-09-14 15:27:17-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-09-16 13:12:47-07:00
log3e3b0b835c178397bb3f8ac4fa0676382e481392
treeb53ee6a6c1ab2d4612bd64eed2e41b4ba45253db
parent3bb9f1847b373256f495fdc602c5ab6a9f6e7724

std.Build.Cache: fix addDiscoveredManifest


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

lib/std/Build/Cache.zig+6-4
...@@ -2115,6 +2115,7 @@ pub const Manifest = struct {...@@ -2115,6 +2115,7 @@ pub const Manifest = struct {
2115 assert(@typeInfo(std.zig.Server.Message.PathPrefix).@"enum".field_names.len == discovered.cache.prefixes_len);2115 assert(@typeInfo(std.zig.Server.Message.PathPrefix).@"enum".field_names.len == discovered.cache.prefixes_len);
2116 assert(discovered.cache.prefixes_len == 5);2116 assert(discovered.cache.prefixes_len == 5);
21172117
2118 const discovered_files = discovered.files.keys();
2118 const orig_files_len = m.files.count();2119 const orig_files_len = m.files.count();
2119 const orig_contents_len = m.contents.items.len;2120 const orig_contents_len = m.contents.items.len;
2120 errdefer {2121 errdefer {
...@@ -2122,13 +2123,14 @@ pub const Manifest = struct {...@@ -2122,13 +2123,14 @@ pub const Manifest = struct {
2122 m.contents.shrinkRetainingCapacity(orig_contents_len);2123 m.contents.shrinkRetainingCapacity(orig_contents_len);
2123 }2124 }
21242125
2125 for (discovered.files.keys(), 0..) |off, file_index| {2126 for (discovered_files, 0..) |off, file_index| {
2126 try m.files.ensureUnusedCapacityContext(gpa, 1, .{ .contents = m.contents.items });2127 try m.files.ensureUnusedCapacityContext(gpa, 1, .{ .contents = m.contents.items });
21272128
2128 const next_off = if (file_index < discovered.files.count())2129 const next_index = file_index + 1;
2129 @backingInt(discovered.files.keys()[file_index + 1])2130 const next_off = if (discovered_files.len - next_index == 0)
2131 discovered.contents.items.len
2130 else2132 else
2131 discovered.contents.items.len;2133 @backingInt(discovered_files[next_index]);
21322134
2133 const copy_bytes = discovered.contents.items[@backingInt(off)..next_off];2135 const copy_bytes = discovered.contents.items[@backingInt(off)..next_off];
2134 const prev_contents_len: File.Offset = @fromBackingInt(@intCast(m.contents.items.len));2136 const prev_contents_len: File.Offset = @fromBackingInt(@intCast(m.contents.items.len));