aboutsummaryrefslogtreecommitdiff
path: root/src/InternPool.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2023-06-20 13:48:19 -0400
committerJacob Young <jacobly0@users.noreply.github.com>2023-06-20 14:02:09 -0400
commit52ec121469d7bf10116fb22c122cbce8ceddd028 (patch)
treedc37b0986aecc60639e4b2e105c4740a14dd8c58 /src/InternPool.zig
parentd7bd4f339c90b9ce07283600cb7ef129912ceef3 (diff)
downloadzig-52ec121469d7bf10116fb22c122cbce8ceddd028.tar.gz
zig-52ec121469d7bf10116fb22c122cbce8ceddd028.zip
Sema: optimize callers of `indexToKey`
Diffstat (limited to 'src/InternPool.zig')
-rw-r--r--src/InternPool.zig19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/InternPool.zig b/src/InternPool.zig
index f93539daf8..d77b82932c 100644
--- a/src/InternPool.zig
+++ b/src/InternPool.zig
@@ -5694,11 +5694,26 @@ pub fn aggregateTypeLenIncludingSentinel(ip: *const InternPool, ty: Index) u64 {
};
}
+pub fn funcReturnType(ip: *const InternPool, ty: Index) Index {
+ const item = ip.items.get(@intFromEnum(ty));
+ const child_item = switch (item.tag) {
+ .type_pointer => ip.items.get(ip.extra.items[
+ item.data + std.meta.fieldIndex(Tag.TypePointer, "child").?
+ ]),
+ .type_function => item,
+ else => unreachable,
+ };
+ assert(child_item.tag == .type_function);
+ return @enumFromInt(Index, ip.extra.items[
+ child_item.data + std.meta.fieldIndex(TypeFunction, "return_type").?
+ ]);
+}
+
pub fn isNoReturn(ip: *const InternPool, ty: Index) bool {
return switch (ty) {
.noreturn_type => true,
- else => switch (ip.indexToKey(ty)) {
- .error_set_type => |error_set_type| error_set_type.names.len == 0,
+ else => switch (ip.items.items(.tag)[@intFromEnum(ty)]) {
+ .type_error_set => ip.extra.items[ip.items.items(.data)[@intFromEnum(ty)] + std.meta.fieldIndex(ErrorSet, "names_len").?] == 0,
else => false,
},
};