From 18815594e8681a307de30410a8f14dde8393ab20 Mon Sep 17 00:00:00 2001 From: Lukas Lalinsky Date: Sat, 5 Sep 2026 06:04:14 +0000 Subject: [PATCH] chore: remove dead UnionAsMapOptions fields omit_nulls and omit_defaults were declared on UnionAsMapOptions and never read, in either direction. They are copy-paste from StructAsMapOptions, where both are genuinely used by isStructFieldUsed on the encode side. They are also meaningless here: packUnionAsMap always writes packMapHeader(writer, 1), one entry for the active variant, so there is nothing to omit. Same category as the surface removed in #27, and no behaviour change since nothing consulted them. --- CHANGELOG.md | 3 +++ src/union.zig | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1293031..5703301 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Decoding an optional is about 18% cheaper, by letting each type's own unpacker recognise a nil header instead of testing for one beforehand +### Removed +- `omit_nulls` and `omit_defaults` on `UnionAsMapOptions`, which were never read; a union-as-map always writes exactly one entry, so there is nothing to omit + ### Fixed - Decoding an enum whose tag names no field returns `error.InvalidEnumTag` instead of being illegal behavior; non-exhaustive enums still accept unknown tags diff --git a/src/union.zig b/src/union.zig index 0958d8e..b76ea08 100644 --- a/src/union.zig +++ b/src/union.zig @@ -35,8 +35,6 @@ pub const UnionAsMapOptions = struct { field_name_prefix: u8, field_index, }, - omit_nulls: bool = true, - omit_defaults: bool = false, }; pub const UnionAsTaggedOptions = struct {