From 52ec121469d7bf10116fb22c122cbce8ceddd028 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Tue, 20 Jun 2023 13:48:19 -0400 Subject: Sema: optimize callers of `indexToKey` --- src/Sema.zig | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'src/Sema.zig') diff --git a/src/Sema.zig b/src/Sema.zig index 761dacf547..7d4c4a6240 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -33817,18 +33817,25 @@ pub fn resolveTypeFields(sema: *Sema, ty: Type) CompileError!Type { .call_modifier_type => return sema.getBuiltinType("CallModifier"), .prefetch_options_type => return sema.getBuiltinType("PrefetchOptions"), - _ => switch (mod.intern_pool.indexToKey(ty.toIntern())) { - .struct_type => |struct_type| { - const struct_obj = mod.structPtrUnwrap(struct_type.index) orelse return ty; - try sema.resolveTypeFieldsStruct(ty, struct_obj); - return ty; - }, - .union_type => |union_type| { - const union_obj = mod.unionPtr(union_type.index); - try sema.resolveTypeFieldsUnion(ty, union_obj); - return ty; + _ => switch (mod.intern_pool.items.items(.tag)[@intFromEnum(ty.toIntern())]) { + .type_struct, + .type_struct_ns, + .type_union_tagged, + .type_union_untagged, + .type_union_safety, + => switch (mod.intern_pool.indexToKey(ty.toIntern())) { + .struct_type => |struct_type| { + const struct_obj = mod.structPtrUnwrap(struct_type.index) orelse return ty; + try sema.resolveTypeFieldsStruct(ty, struct_obj); + return ty; + }, + .union_type => |union_type| { + const union_obj = mod.unionPtr(union_type.index); + try sema.resolveTypeFieldsUnion(ty, union_obj); + return ty; + }, + else => unreachable, }, - else => return ty, }, } -- cgit v1.2.3