diff options
| author | Matthew Lugg <mlugg@mlugg.co.uk> | 2025-10-28 12:42:05 +0000 |
|---|---|---|
| committer | Matthew Lugg <mlugg@mlugg.co.uk> | 2025-10-30 09:31:28 +0000 |
| commit | 74931fe25cdd94e1cd08b5ece9dcce19959bc079 (patch) | |
| tree | 75449b1d594d55a872aeb03f2dd3be16ac396274 /src/main.zig | |
| parent | 74c23a237ef5245b63eb06b832a511aabeb715c0 (diff) | |
| download | zig-74931fe25cdd94e1cd08b5ece9dcce19959bc079.tar.gz zig-74931fe25cdd94e1cd08b5ece9dcce19959bc079.zip | |
std.debug.lockStderrWriter: also return ttyconf
`std.Io.tty.Config.detect` may be an expensive check (e.g. involving
syscalls), and doing it every time we need to print isn't really
necessary; under normal usage, we can compute the value once and cache
it for the whole program's execution. Since anyone outputting to stderr
may reasonably want this information (in fact they are very likely to),
it makes sense to cache it and return it from `lockStderrWriter`. Call
sites who do not need it will experience no significant overhead, and
can just ignore the TTY config with a `const w, _` destructure.
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/main.zig b/src/main.zig index 03d42ba898..d134dd9bd2 100644 --- a/src/main.zig +++ b/src/main.zig @@ -4520,7 +4520,7 @@ fn updateModule(comp: *Compilation, color: Color, prog_node: std.Progress.Node) defer errors.deinit(comp.gpa); if (errors.errorMessageCount() > 0) { - errors.renderToStdErr(color.renderOptions()); + errors.renderToStdErr(.{}, color); return error.CompileErrorsReported; } } @@ -4573,7 +4573,7 @@ fn cmdTranslateC( return; } else { const color: Color = .auto; - result.errors.renderToStdErr(color.renderOptions()); + result.errors.renderToStdErr(.{}, color); process.exit(1); } } @@ -5199,7 +5199,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8) if (fetch.error_bundle.root_list.items.len > 0) { var errors = try fetch.error_bundle.toOwnedBundle(""); - errors.renderToStdErr(color.renderOptions()); + errors.renderToStdErr(.{}, color); process.exit(1); } @@ -6135,7 +6135,7 @@ fn cmdAstCheck(arena: Allocator, io: Io, args: []const []const u8) !void { try wip_errors.init(arena); try wip_errors.addZirErrorMessages(zir, tree, source, display_path); var error_bundle = try wip_errors.toOwnedBundle(""); - error_bundle.renderToStdErr(color.renderOptions()); + error_bundle.renderToStdErr(.{}, color); if (zir.loweringFailed()) { process.exit(1); } @@ -6206,7 +6206,7 @@ fn cmdAstCheck(arena: Allocator, io: Io, args: []const []const u8) !void { try wip_errors.init(arena); try wip_errors.addZoirErrorMessages(zoir, tree, source, display_path); var error_bundle = try wip_errors.toOwnedBundle(""); - error_bundle.renderToStdErr(color.renderOptions()); + error_bundle.renderToStdErr(.{}, color); process.exit(1); } @@ -6479,7 +6479,7 @@ fn cmdChangelist(arena: Allocator, io: Io, args: []const []const u8) !void { try wip_errors.init(arena); try wip_errors.addZirErrorMessages(old_zir, old_tree, old_source, old_source_path); var error_bundle = try wip_errors.toOwnedBundle(""); - error_bundle.renderToStdErr(color.renderOptions()); + error_bundle.renderToStdErr(.{}, color); process.exit(1); } @@ -6491,7 +6491,7 @@ fn cmdChangelist(arena: Allocator, io: Io, args: []const []const u8) !void { try wip_errors.init(arena); try wip_errors.addZirErrorMessages(new_zir, new_tree, new_source, new_source_path); var error_bundle = try wip_errors.toOwnedBundle(""); - error_bundle.renderToStdErr(color.renderOptions()); + error_bundle.renderToStdErr(.{}, color); process.exit(1); } @@ -6948,7 +6948,7 @@ fn cmdFetch( if (fetch.error_bundle.root_list.items.len > 0) { var errors = try fetch.error_bundle.toOwnedBundle(""); - errors.renderToStdErr(color.renderOptions()); + errors.renderToStdErr(.{}, color); process.exit(1); } @@ -7304,7 +7304,7 @@ fn loadManifest( var error_bundle = try wip_errors.toOwnedBundle(""); defer error_bundle.deinit(gpa); - error_bundle.renderToStdErr(options.color.renderOptions()); + error_bundle.renderToStdErr(.{}, options.color); process.exit(2); } |
