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 fb25f1e commit cf3e80e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions vlib/v/gen/c/auto_eq_methods.v
Original file line number Diff line number Diff line change
Expand Up @@ -437,18 +437,18 @@ 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_type.has_flag(.option) {
fn_builder.writeln('\tif (a.state != b.state) return false;')
fn_builder.writeln('\tif (a.state == 2 && a.state == b.state) return true;')
}
if left_typ.sym.is_primitive_fixed_array() {
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.write_string('\tif (!memcmp(&a${suffix}, &b${suffix}, sizeof(${size_styp}))) {')
fn_builder.writeln('\t\treturn true;')
fn_builder.writeln('\t}')
}
Expand Down

0 comments on commit cf3e80e

Please sign in to comment.