diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2023-06-20 13:48:19 -0400 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2023-06-20 14:02:09 -0400 |
| commit | 52ec121469d7bf10116fb22c122cbce8ceddd028 (patch) | |
| tree | dc37b0986aecc60639e4b2e105c4740a14dd8c58 /src/Sema.zig | |
| parent | d7bd4f339c90b9ce07283600cb7ef129912ceef3 (diff) | |
| download | zig-52ec121469d7bf10116fb22c122cbce8ceddd028.tar.gz zig-52ec121469d7bf10116fb22c122cbce8ceddd028.zip | |
Sema: optimize callers of `indexToKey`
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 29 |
1 files changed, 18 insertions, 11 deletions
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, }, } |
