authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-06-20 13:38:10-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-06-20 14:02:08-04:00
logd69e324eae6d245a4b0c75c0a8ce91275dfcc938
tree2a02dad7932cb4b9ba431680edbf7c83b4694305
parentad3e0e4eb4afc3f633f5f8f04affc3e9ff886cb6

Value: optimize `isRuntimeValue`


2 files changed, 5 insertions(+), 1 deletions(-)

src/InternPool.zig+4
......@@ -5702,6 +5702,10 @@ pub fn isNoReturn(ip: *const InternPool, ty: Index) bool {
57025702 };
57035703}
57045704
5705pub fn isRuntimeValue(ip: *const InternPool, val: Index) bool {
5706 return ip.items.items(.tag)[@intFromEnum(val)] == .runtime_value;
5707}
5708
57055709/// This is a particularly hot function, so we operate directly on encodings
57065710/// rather than the more straightforward implementation of calling `indexToKey`.
57075711pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPoison}!std.builtin.TypeId {
src/value.zig+1-1
......@@ -1823,7 +1823,7 @@ pub const Value = struct {
18231823 }
18241824
18251825 pub fn isRuntimeValue(val: Value, mod: *Module) bool {
1826 return mod.intern_pool.indexToKey(val.toIntern()) == .runtime_value;
1826 return mod.intern_pool.isRuntimeValue(val.toIntern());
18271827 }
18281828
18291829 /// Returns true if a Value is backed by a variable