mirror of
https://github.com/vlang/v.git
synced 2025-09-07 22:30:57 -04:00
cgen: cleanup gen_fixed_array_equality_fn, rm repeated calls (#23672)
This commit is contained in:
parent
8bbaab396f
commit
4f0e03540a
@ -432,18 +432,19 @@ fn (mut g Gen) gen_fixed_array_equality_fn(left_type ast.Type) string {
|
|||||||
}
|
}
|
||||||
g.definitions.writeln('bool ${ptr_styp}_arr_eq(${arg_styp} a, ${arg_styp} b); // auto')
|
g.definitions.writeln('bool ${ptr_styp}_arr_eq(${arg_styp} a, ${arg_styp} b); // auto')
|
||||||
|
|
||||||
left := if left_type.has_flag(.option) { 'a.data' } else { 'a' }
|
is_option := left_type.has_flag(.option)
|
||||||
right := if left_type.has_flag(.option) { 'b.data' } else { 'b' }
|
left := if is_option { 'a.data' } else { 'a' }
|
||||||
|
right := if is_option { 'b.data' } else { 'b' }
|
||||||
|
|
||||||
mut fn_builder := strings.new_builder(512)
|
mut fn_builder := strings.new_builder(512)
|
||||||
fn_builder.writeln('inline bool ${ptr_styp}_arr_eq(${arg_styp} a, ${arg_styp} b) {')
|
fn_builder.writeln('inline bool ${ptr_styp}_arr_eq(${arg_styp} a, ${arg_styp} b) {')
|
||||||
if left_type.has_flag(.option) {
|
if is_option {
|
||||||
fn_builder.writeln('\tif (a.state != b.state) return false;')
|
fn_builder.writeln('\tif (a.state != b.state) return false;')
|
||||||
fn_builder.writeln('\tif (a.state == 2 && a.state == b.state) return true;')
|
fn_builder.writeln('\tif (a.state == 2 && a.state == b.state) return true;')
|
||||||
}
|
}
|
||||||
if left_typ.sym.is_primitive_fixed_array() {
|
if left_typ.sym.is_primitive_fixed_array() {
|
||||||
suffix := if left_type.has_flag(.option) { '.data' } else { '[0]' }
|
suffix := if is_option { '.data' } else { '[0]' }
|
||||||
size_styp := if left_type.has_flag(.option) {
|
size_styp := if is_option {
|
||||||
g.base_type(left_typ.typ.set_nr_muls(0))
|
g.base_type(left_typ.typ.set_nr_muls(0))
|
||||||
} else {
|
} else {
|
||||||
arg_styp
|
arg_styp
|
||||||
|
Loading…
x
Reference in New Issue
Block a user