mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
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.
This commit is contained in:
parent
fbe0ae4fd4
commit
9ba9f457be
11
src/Sema.zig
11
src/Sema.zig
@ -33930,6 +33930,17 @@ fn resolvePeerTypes(
|
|||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fast path: check if everything has the same type to bypass the main PTR logic.
|
||||||
|
same_type: {
|
||||||
|
const ty = sema.typeOf(instructions[0]);
|
||||||
|
for (instructions[1..]) |inst| {
|
||||||
|
if (sema.typeOf(inst).toIntern() != ty.toIntern()) {
|
||||||
|
break :same_type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ty;
|
||||||
|
}
|
||||||
|
|
||||||
const peer_tys = try sema.arena.alloc(?Type, instructions.len);
|
const peer_tys = try sema.arena.alloc(?Type, instructions.len);
|
||||||
const peer_vals = try sema.arena.alloc(?Value, instructions.len);
|
const peer_vals = try sema.arena.alloc(?Value, instructions.len);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user