1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

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

This commit is contained in:
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

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('\tfor (int i = 0; i < a.len; ++i, ++pelem) {')
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() {
ptr_typ := g.gen_array_equality_fn(info.elem_type)
fn_builder.writeln('\t\tif (${ptr_typ}_arr_eq( *pelem, v)) {')