diff options
| author | jacob gw <jacoblevgw@gmail.com> | 2021-02-26 09:56:16 -0500 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2021-02-28 22:01:13 +0200 |
| commit | 58b14d01aeb919989d1750a8894350a07fd4e844 (patch) | |
| tree | 574dbe169aa0fba72b8901333a82c9e3e5d11c51 /src | |
| parent | 1f17221bc4e17bcd7116fe12ab3f939346179799 (diff) | |
| download | zig-58b14d01aeb919989d1750a8894350a07fd4e844.tar.gz zig-58b14d01aeb919989d1750a8894350a07fd4e844.zip | |
stage2: remove value field from error
This saves memory and from what I have heard allows threading
to be easier.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Module.zig | 1 | ||||
| -rw-r--r-- | src/value.zig | 2 | ||||
| -rw-r--r-- | src/zir_sema.zig | 4 |
3 files changed, 2 insertions, 5 deletions
diff --git a/src/Module.zig b/src/Module.zig index 21dc953262..3a72f1272b 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -4101,7 +4101,6 @@ pub fn namedFieldPtr( scope.arena(), try Value.Tag.@"error".create(scope.arena(), .{ .name = entry.key, - .value = entry.value, }), ), }); diff --git a/src/value.zig b/src/value.zig index 0a6a48dbf7..ae94e4b424 100644 --- a/src/value.zig +++ b/src/value.zig @@ -1561,7 +1561,6 @@ pub const Value = extern union { .@"error" => { const payload = self.castTag(.@"error").?.data; hasher.update(payload.name); - std.hash.autoHash(&hasher, payload.value); }, .error_union => { const payload = self.castTag(.error_union).?.data; @@ -2157,7 +2156,6 @@ pub const Value = extern union { /// duration of the compilation. /// TODO revisit this when we have the concept of the error tag type name: []const u8, - value: u16, }, }; diff --git a/src/zir_sema.zig b/src/zir_sema.zig index 8da4fd9eff..864f766f54 100644 --- a/src/zir_sema.zig +++ b/src/zir_sema.zig @@ -1178,7 +1178,6 @@ fn zirErrorValue(mod: *Module, scope: *Scope, inst: *zir.Inst.ErrorValue) InnerE .ty = result_type, .val = try Value.Tag.@"error".create(scope.arena(), .{ .name = entry.key, - .value = entry.value, }), }); } @@ -2215,7 +2214,8 @@ fn zirCmp( } if (rhs.value()) |rval| { if (lhs.value()) |lval| { - return mod.constBool(scope, inst.base.src, (lval.castTag(.@"error").?.data.value == rval.castTag(.@"error").?.data.value) == (op == .eq)); + // TODO optimisation oppurtunity: evaluate if std.mem.eql is faster with the names, or calling to Module.getErrorValue to get the values and then compare them is faster + return mod.constBool(scope, inst.base.src, std.mem.eql(u8, lval.castTag(.@"error").?.data.name, rval.castTag(.@"error").?.data.name) == (op == .eq)); } } return mod.fail(scope, inst.base.src, "TODO implement equality comparison between runtime errors", .{}); |
