authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-19 22:18:04-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-19 22:18:04-07:00
log41eff5723dd61b19be88830f16d76514583e3339
treee1a0469d807448c2814249a3e4509ddb65bc1b52
parent46d592e485cf8ee4d85854040acd1b05271591b5

Compilation: avoid caching root source file twice

The deleted lines here are redundant because they happen first thing inside the function call below. Additionally, skip hashing the root source file if it is an empty string. I explored making this field along with `root` optional but found this to be less messy actually.

1 files changed, 1 insertions(+), 3 deletions(-)

src/Compilation.zig+1-3
...@@ -1170,7 +1170,7 @@ fn addModuleTableToCacheHash(...@@ -1170,7 +1170,7 @@ fn addModuleTableToCacheHash(
1170 hash.addOptionalBytes(mod.root.root_dir.path);1170 hash.addOptionalBytes(mod.root.root_dir.path);
1171 hash.addBytes(mod.root.sub_path);1171 hash.addBytes(mod.root.sub_path);
1172 },1172 },
1173 .files => |man| {1173 .files => |man| if (mod.root_src_path.len != 0) {
1174 const pkg_zig_file = try mod.root.joinString(arena, mod.root_src_path);1174 const pkg_zig_file = try mod.root.joinString(arena, mod.root_src_path);
1175 _ = try man.addFile(pkg_zig_file, null);1175 _ = try man.addFile(pkg_zig_file, null);
1176 },1176 },
...@@ -2467,8 +2467,6 @@ fn addNonIncrementalStuffToCacheManifest(...@@ -2467,8 +2467,6 @@ fn addNonIncrementalStuffToCacheManifest(
2467 comptime assert(link_hash_implementation_version == 11);2467 comptime assert(link_hash_implementation_version == 11);
24682468
2469 if (comp.module) |mod| {2469 if (comp.module) |mod| {
2470 const main_zig_file = try mod.main_mod.root.joinString(arena, mod.main_mod.root_src_path);
2471 _ = try man.addFile(main_zig_file, null);
2472 try addModuleTableToCacheHash(gpa, arena, &man.hash, mod.root_mod, mod.main_mod, .{ .files = man });2470 try addModuleTableToCacheHash(gpa, arena, &man.hash, mod.root_mod, mod.main_mod, .{ .files = man });
24732471
2474 // Synchronize with other matching comments: ZigOnlyHashStuff2472 // Synchronize with other matching comments: ZigOnlyHashStuff