cgen: fix check for array equality
parent
e8afd7a1b7
commit
df825506fd
|
@ -2084,11 +2084,11 @@ fn (g mut Gen) generate_array_equality_fn(ptr_typ string, styp table.Type, sym &
|
||||||
g.definitions.writeln('\t}')
|
g.definitions.writeln('\t}')
|
||||||
g.definitions.writeln('\tfor (int i = 0; i < a.len; i++) {')
|
g.definitions.writeln('\tfor (int i = 0; i < a.len; i++) {')
|
||||||
if styp == table.string_type_idx {
|
if styp == table.string_type_idx {
|
||||||
g.definitions.writeln('\t\tif (string_ne(*((${ptr_typ}*)(a.data+(i*a.element_size))), *((${ptr_typ}*)(b.data+(i*b.element_size))))) {')
|
g.definitions.writeln('\t\tif (string_ne(*((${ptr_typ}*)((byte*)a.data+(i*a.element_size))), *((${ptr_typ}*)((byte*)b.data+(i*b.element_size))))) {')
|
||||||
} else if sym.kind == .struct_ {
|
} else if sym.kind == .struct_ {
|
||||||
g.definitions.writeln('\t\tif (memcmp((void*)(a.data+(i*a.element_size)), (void*)(b.data+(i*b.element_size)), a.element_size)) {')
|
g.definitions.writeln('\t\tif (memcmp((byte*)a.data+(i*a.element_size), (byte*)b.data+(i*b.element_size), a.element_size)) {')
|
||||||
} else {
|
} else {
|
||||||
g.definitions.writeln('\t\tif (*((${ptr_typ}*)(a.data+(i*a.element_size))) != *((${ptr_typ}*)(b.data+(i*b.element_size)))) {')
|
g.definitions.writeln('\t\tif (*((${ptr_typ}*)((byte*)a.data+(i*a.element_size))) != *((${ptr_typ}*)((byte*)b.data+(i*b.element_size)))) {')
|
||||||
}
|
}
|
||||||
g.definitions.writeln('\t\t\treturn false;')
|
g.definitions.writeln('\t\t\treturn false;')
|
||||||
g.definitions.writeln('\t\t}')
|
g.definitions.writeln('\t\t}')
|
||||||
|
|
Loading…
Reference in New Issue