authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-02-05 19:56:43+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-02-05 19:56:43+00:00
log9ba9f457be13c0c32981e94cf75ba7ea6619d92f
tree5908f90027db6a17b3099e44e5c4df4c80bab8c2
parentfbe0ae4fd4128a3652071b4b5985d68ae56e9992
signaturelock-open Commit is signed but in an unrecognized format.

Sema: add fast path to PTR when all types are the same

I have no idea why I didn't add this when I first implemented this PTR logic.

1 files changed, 11 insertions(+), 0 deletions(-)

src/Sema.zig+11
......@@ -33930,6 +33930,17 @@ fn resolvePeerTypes(
3393033930 else => {},
3393133931 }
3393233932
33933 // Fast path: check if everything has the same type to bypass the main PTR logic.
33934 same_type: {
33935 const ty = sema.typeOf(instructions[0]);
33936 for (instructions[1..]) |inst| {
33937 if (sema.typeOf(inst).toIntern() != ty.toIntern()) {
33938 break :same_type;
33939 }
33940 }
33941 return ty;
33942 }
33943
3393333944 const peer_tys = try sema.arena.alloc(?Type, instructions.len);
3393433945 const peer_vals = try sema.arena.alloc(?Value, instructions.len);
3393533946