mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Don't check if the same files exist 248 extra times (#16747)
This commit is contained in:
11
build.zig
11
build.zig
@@ -152,6 +152,7 @@ pub fn getCpuModel(os: OperatingSystem, arch: Arch) ?Target.Query.CpuModel {
|
||||
|
||||
pub fn build(b: *Build) !void {
|
||||
std.log.info("zig compiler v{s}", .{builtin.zig_version_string});
|
||||
checked_file_exists = std.AutoHashMap(u64, void).init(b.allocator);
|
||||
|
||||
b.zig_lib_dir = b.zig_lib_dir orelse b.path("vendor/zig/lib");
|
||||
|
||||
@@ -481,9 +482,15 @@ pub fn addInstallObjectFile(
|
||||
}, b.fmt("{s}.o", .{name})).step;
|
||||
}
|
||||
|
||||
var checked_file_exists: std.AutoHashMap(u64, void) = undefined;
|
||||
fn exists(path: []const u8) bool {
|
||||
const file = std.fs.openFileAbsolute(path, .{ .mode = .read_only }) catch return false;
|
||||
file.close();
|
||||
const entry = checked_file_exists.getOrPut(std.hash.Wyhash.hash(0, path)) catch unreachable;
|
||||
if (entry.found_existing) {
|
||||
// It would've panicked.
|
||||
return true;
|
||||
}
|
||||
|
||||
std.fs.accessAbsolute(path, .{ .mode = .read_only }) catch return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user