1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

ast: minor optimization in sumtype_check_function_variant() (#15694)

This commit is contained in:
yuyi 2022-09-08 14:20:30 +08:00 committed by GitHub
parent a75a12ec1e
commit a462610376
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1307,18 +1307,18 @@ pub fn (t &Table) sumtype_has_variant(parent Type, variant Type, is_as bool) boo
}
fn (t &Table) sumtype_check_function_variant(parent_info SumType, variant Type, is_as bool) bool {
variant_fn := (t.sym(variant).info as FnType).func
variant_fn_sig := t.fn_type_source_signature(variant_fn)
for v in parent_info.variants {
v_sym := t.sym(v)
if v_sym.kind != .function {
continue
}
v_fn := (v_sym.info as FnType).func
variant_fn := (t.sym(variant).info as FnType).func
if t.fn_type_source_signature(v_fn) == t.fn_type_source_signature(variant_fn)
if v_sym.info is FnType {
if t.fn_type_source_signature(v_sym.info.func) == variant_fn_sig
&& (!is_as || v.nr_muls() == variant.nr_muls()) {
return true
}
}
}
return false
}