From d69e324eae6d245a4b0c75c0a8ce91275dfcc938 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Tue, 20 Jun 2023 13:38:10 -0400 Subject: [PATCH] Value: optimize `isRuntimeValue` --- src/InternPool.zig | 4 ++++ src/value.zig | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/InternPool.zig b/src/InternPool.zig index 5463bc4192..7cddfef693 100644 --- a/src/InternPool.zig +++ b/src/InternPool.zig @@ -5702,6 +5702,10 @@ pub fn isNoReturn(ip: *const InternPool, ty: Index) bool { }; } +pub fn isRuntimeValue(ip: *const InternPool, val: Index) bool { + return ip.items.items(.tag)[@intFromEnum(val)] == .runtime_value; +} + /// This is a particularly hot function, so we operate directly on encodings /// rather than the more straightforward implementation of calling `indexToKey`. pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPoison}!std.builtin.TypeId { diff --git a/src/value.zig b/src/value.zig index f348ce2edb..00c8fa924c 100644 --- a/src/value.zig +++ b/src/value.zig @@ -1823,7 +1823,7 @@ pub const Value = struct { } pub fn isRuntimeValue(val: Value, mod: *Module) bool { - return mod.intern_pool.indexToKey(val.toIntern()) == .runtime_value; + return mod.intern_pool.isRuntimeValue(val.toIntern()); } /// Returns true if a Value is backed by a variable