authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-11 22:49:08-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-11 22:49:08-07:00
logb3259b47ad03592a156841c87e69421da05e37f3
tree5e155833e83686971f373d8d59b936a8b67e9aa8
parentf6b479b81d3e893f1240a2fc03397d519987f850

Type.eql: check fn attributes before params

slightly better for cache locality

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

src/type.zig+11-10
......@@ -558,7 +558,7 @@ pub const Type = extern union {
558558
559559 .error_set_inferred => {
560560 // Inferred error sets are only equal if both are inferred
561 // and they originate from the exact same function.
561 // and they share the same pointer.
562562 const a_ies = a.castTag(.error_set_inferred).?.data;
563563 const b_ies = (b.castTag(.error_set_inferred) orelse return false).data;
564564 return a_ies == b_ies;
......@@ -612,6 +612,15 @@ pub const Type = extern union {
612612 if (a_info.cc != b_info.cc)
613613 return false;
614614
615 if (a_info.alignment != b_info.alignment)
616 return false;
617
618 if (a_info.is_var_args != b_info.is_var_args)
619 return false;
620
621 if (a_info.is_generic != b_info.is_generic)
622 return false;
623
615624 if (a_info.param_types.len != b_info.param_types.len)
616625 return false;
617626
......@@ -622,19 +631,11 @@ pub const Type = extern union {
622631
623632 if (a_param_ty.tag() == .generic_poison) continue;
624633 if (b_param_ty.tag() == .generic_poison) continue;
634
625635 if (!eql(a_param_ty, b_param_ty))
626636 return false;
627637 }
628638
629 if (a_info.alignment != b_info.alignment)
630 return false;
631
632 if (a_info.is_var_args != b_info.is_var_args)
633 return false;
634
635 if (a_info.is_generic != b_info.is_generic)
636 return false;
637
638639 return true;
639640 },
640641