Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Dec 15, 2024
1 parent b92553c commit 675ef17
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions vlib/v/gen/c/auto_eq_methods.v
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,17 @@ fn (mut g Gen) gen_fixed_array_equality_fn(left_type ast.Type) string {
mut fn_builder := strings.new_builder(512)
fn_builder.writeln('inline bool ${ptr_styp}_arr_eq(${arg_styp} a, ${arg_styp} b) {')
if left_typ.sym.is_primitive_fixed_array() {
suffix := if left_type.has_flag(.option) { '' } else { '[0]' }
fn_builder.writeln('\tif (!memcmp(&a${suffix}, &b${suffix}, sizeof(${arg_styp}))) {')
suffix := if left_type.has_flag(.option) { '.data' } else { '[0]' }
size_styp := if left_type.has_flag(.option) {
g.base_type(left_typ.typ.set_nr_muls(0))
} else {
arg_styp
}
fn_builder.write_string('\tif (')
if left_type.has_flag(.option) {
fn_builder.write_string('(a.state == b.state && a.state == 2) || ')
}
fn_builder.writeln('!memcmp(&a${suffix}, &b${suffix}, sizeof(${size_styp}))) {')
fn_builder.writeln('\t\treturn true;')
fn_builder.writeln('\t}')
}
Expand Down

0 comments on commit 675ef17

Please sign in to comment.