aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/c.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-12-02 15:42:20 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-12-02 15:42:20 -0700
commitd171279d7965137ac835f2ed6d48517478508eae (patch)
tree921484f7afd0f9519e869a30cbaaa19f311465b5 /src/codegen/c.zig
parentaf4361f57af388238a075b0c8ef5b34e75b73787 (diff)
downloadzig-d171279d7965137ac835f2ed6d48517478508eae.tar.gz
zig-d171279d7965137ac835f2ed6d48517478508eae.zip
CBE: use a 0 literal instead of `error.@"(no error)"`
This saves bytes and is easier to read too.
Diffstat (limited to 'src/codegen/c.zig')
-rw-r--r--src/codegen/c.zig6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index d7aec355e9..e38aedb125 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -1141,8 +1141,10 @@ pub const DeclGen = struct {
if (!payload_ty.hasRuntimeBits()) {
// We use the error type directly as the type.
- const err_val = if (val.errorUnionIsPayload()) Value.initTag(.zero) else val;
- return dg.renderValue(writer, error_ty, err_val, location);
+ if (val.errorUnionIsPayload()) {
+ return try writer.writeByte('0');
+ }
+ return dg.renderValue(writer, error_ty, val, location);
}
if (location != .Initializer) {