aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-05-29 13:47:13 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-06-10 20:47:56 -0700
commit804740af4ced8389e21df31a908c4212e32a477a (patch)
treec136a0f3f8693edc8a9cca0475b3d7700f5076c4 /src
parent5580a69d714af92883e2031a131c30917162dc15 (diff)
downloadzig-804740af4ced8389e21df31a908c4212e32a477a.tar.gz
zig-804740af4ced8389e21df31a908c4212e32a477a.zip
InternPool: avoid indexToKey recursion for type_slice
This is a hot function, and recursion makes it more difficult to profile, as well as likely making it more difficult to optimize.
Diffstat (limited to 'src')
-rw-r--r--src/InternPool.zig19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/InternPool.zig b/src/InternPool.zig
index 7bfecf46b6..008f0f4df1 100644
--- a/src/InternPool.zig
+++ b/src/InternPool.zig
@@ -2455,10 +2455,21 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
},
.type_slice => {
- const ptr_type_index = @intToEnum(Index, data);
- var result = ip.indexToKey(ptr_type_index).ptr_type;
- result.size = .Slice;
- return .{ .ptr_type = result };
+ assert(ip.items.items(.tag)[data] == .type_pointer);
+ const ptr_info = ip.extraData(Pointer, ip.items.items(.data)[data]);
+ return .{ .ptr_type = .{
+ .elem_type = ptr_info.child,
+ .sentinel = ptr_info.sentinel,
+ .alignment = ptr_info.flags.alignment,
+ .size = .Slice,
+ .is_const = ptr_info.flags.is_const,
+ .is_volatile = ptr_info.flags.is_volatile,
+ .is_allowzero = ptr_info.flags.is_allowzero,
+ .address_space = ptr_info.flags.address_space,
+ .vector_index = ptr_info.flags.vector_index,
+ .host_size = ptr_info.packed_offset.host_size,
+ .bit_offset = ptr_info.packed_offset.bit_offset,
+ } };
},
.type_optional => .{ .opt_type = @intToEnum(Index, data) },