authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-05-29 13:47:13-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-10 20:47:56-07:00
log804740af4ced8389e21df31a908c4212e32a477a
treec136a0f3f8693edc8a9cca0475b3d7700f5076c4
parent5580a69d714af92883e2031a131c30917162dc15

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.

1 files changed, 15 insertions(+), 4 deletions(-)

src/InternPool.zig+15-4
...@@ -2455,10 +2455,21 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {...@@ -2455,10 +2455,21 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
2455 },2455 },
24562456
2457 .type_slice => {2457 .type_slice => {
2458 const ptr_type_index = @intToEnum(Index, data);2458 assert(ip.items.items(.tag)[data] == .type_pointer);
2459 var result = ip.indexToKey(ptr_type_index).ptr_type;2459 const ptr_info = ip.extraData(Pointer, ip.items.items(.data)[data]);
2460 result.size = .Slice;2460 return .{ .ptr_type = .{
2461 return .{ .ptr_type = result };2461 .elem_type = ptr_info.child,
2462 .sentinel = ptr_info.sentinel,
2463 .alignment = ptr_info.flags.alignment,
2464 .size = .Slice,
2465 .is_const = ptr_info.flags.is_const,
2466 .is_volatile = ptr_info.flags.is_volatile,
2467 .is_allowzero = ptr_info.flags.is_allowzero,
2468 .address_space = ptr_info.flags.address_space,
2469 .vector_index = ptr_info.flags.vector_index,
2470 .host_size = ptr_info.packed_offset.host_size,
2471 .bit_offset = ptr_info.packed_offset.bit_offset,
2472 } };
2462 },2473 },
24632474
2464 .type_optional => .{ .opt_type = @intToEnum(Index, data) },2475 .type_optional => .{ .opt_type = @intToEnum(Index, data) },