commit d171279d7965137ac835f2ed6d48517478508eae (tree)
parent af4361f57af388238a075b0c8ef5b34e75b73787
Author: Andrew Kelley <andrew@ziglang.org>
Date: Fri, 2 Dec 2022 15:42:20 -0700
CBE: use a 0 literal instead of `error.@"(no error)"`
This saves bytes and is easier to read too.
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git 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) {