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 {...@@ -5702,6 +5702,10 @@ pub fn isNoReturn(ip: *const InternPool, ty: Index) bool {
5702 };5702 };
5703}5703}
57045704
5705pub fn isRuntimeValue(ip: *const InternPool, val: Index) bool {
5706 return ip.items.items(.tag)[@intFromEnum(val)] == .runtime_value;
5707}
5708
5705/// This is a particularly hot function, so we operate directly on encodings5709/// This is a particularly hot function, so we operate directly on encodings
5706/// rather than the more straightforward implementation of calling `indexToKey`.5710/// rather than the more straightforward implementation of calling `indexToKey`.
5707pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPoison}!std.builtin.TypeId {5711pub 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 {...@@ -1823,7 +1823,7 @@ pub const Value = struct {
1823 }1823 }
18241824
1825 pub fn isRuntimeValue(val: Value, mod: *Module) bool {1825 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());
1827 }1827 }
18281828
1829 /// Returns true if a Value is backed by a variable1829 /// Returns true if a Value is backed by a variable