From b3259b47ad03592a156841c87e69421da05e37f3 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 11 Mar 2022 22:49:08 -0700 Subject: [PATCH] Type.eql: check fn attributes before params slightly better for cache locality --- src/type.zig | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/type.zig b/src/type.zig index 0bac905ec7..30c8838109 100644 --- a/src/type.zig +++ b/src/type.zig @@ -558,7 +558,7 @@ pub const Type = extern union { .error_set_inferred => { // Inferred error sets are only equal if both are inferred - // and they originate from the exact same function. + // and they share the same pointer. const a_ies = a.castTag(.error_set_inferred).?.data; const b_ies = (b.castTag(.error_set_inferred) orelse return false).data; return a_ies == b_ies; @@ -612,6 +612,15 @@ pub const Type = extern union { if (a_info.cc != b_info.cc) return false; + if (a_info.alignment != b_info.alignment) + return false; + + if (a_info.is_var_args != b_info.is_var_args) + return false; + + if (a_info.is_generic != b_info.is_generic) + return false; + if (a_info.param_types.len != b_info.param_types.len) return false; @@ -622,19 +631,11 @@ pub const Type = extern union { if (a_param_ty.tag() == .generic_poison) continue; if (b_param_ty.tag() == .generic_poison) continue; + if (!eql(a_param_ty, b_param_ty)) return false; } - if (a_info.alignment != b_info.alignment) - return false; - - if (a_info.is_var_args != b_info.is_var_args) - return false; - - if (a_info.is_generic != b_info.is_generic) - return false; - return true; },