v.gen.c: fix generation for `string.index` (#11106)

pull/11112/head
Enzo 2021-08-09 06:39:15 +02:00 committed by GitHub
parent a64b191ce5
commit 1a555ab898
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -526,7 +526,7 @@ fn (mut g Gen) gen_array_index_method(left_type ast.Type) string {
fn_builder.writeln('\t$elem_type_str* pelem = a.data;') fn_builder.writeln('\t$elem_type_str* pelem = a.data;')
fn_builder.writeln('\tfor (int i = 0; i < a.len; ++i, ++pelem) {') fn_builder.writeln('\tfor (int i = 0; i < a.len; ++i, ++pelem) {')
if elem_sym.kind == .string { if elem_sym.kind == .string {
fn_builder.writeln('\t\tif (fast_string_eq(( *pelem, v))) {') fn_builder.writeln('\t\tif (fast_string_eq(*pelem, v)) {')
} else if elem_sym.kind == .array && !info.elem_type.is_ptr() { } else if elem_sym.kind == .array && !info.elem_type.is_ptr() {
ptr_typ := g.gen_array_equality_fn(info.elem_type) ptr_typ := g.gen_array_equality_fn(info.elem_type)
fn_builder.writeln('\t\tif (${ptr_typ}_arr_eq( *pelem, v)) {') fn_builder.writeln('\t\tif (${ptr_typ}_arr_eq( *pelem, v)) {')