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:
parent
a75a12ec1e
commit
a462610376
@ -1307,16 +1307,16 @@ 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)
|
||||
&& (!is_as || v.nr_muls() == variant.nr_muls()) {
|
||||
return true
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user