diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-08-17 14:25:18 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-08-17 18:16:03 -0700 |
| commit | 7ef1eb1c27754cb0349fdc10db1f02ff2dddd99b (patch) | |
| tree | 6a76839d8be347648741e17f50d6c70d8313adc3 /src/value.zig | |
| parent | 8c1329b222ab620d7388d766e9e558baa502ce93 (diff) | |
| download | zig-7ef1eb1c27754cb0349fdc10db1f02ff2dddd99b.tar.gz zig-7ef1eb1c27754cb0349fdc10db1f02ff2dddd99b.zip | |
InternPool: safer enum API
The key changes in this commit are:
```diff
- names: []const NullTerminatedString,
+ names: NullTerminatedString.Slice,
- values: []const Index,
+ values: Index.Slice,
```
Which eliminates the slices from `InternPool.Key.EnumType` and replaces
them with structs that contain `start` and `len` indexes. This makes the
lifetime of `EnumType` change from expiring with updates to InternPool,
to expiring when the InternPool is garbage-collected, which is currently
never.
This is gearing up for a larger change I started working on locally
which moves union types into InternPool.
As a bonus, I fixed some unnecessary instances of `@as`.
Diffstat (limited to 'src/value.zig')
| -rw-r--r-- | src/value.zig | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/value.zig b/src/value.zig index 1a2e85bb1e..fdf061c680 100644 --- a/src/value.zig +++ b/src/value.zig @@ -426,7 +426,7 @@ pub const Value = struct { // Assume it is already an integer and return it directly. .simple_type, .int_type => val, .enum_type => |enum_type| if (enum_type.values.len != 0) - enum_type.values[field_index].toValue() + enum_type.values.get(ip)[field_index].toValue() else // Field index and integer values are the same. mod.intValue(enum_type.tag_ty.toType(), field_index), else => unreachable, |
