From 0ab953acb2b7192c5907a1c9d9ed9cf850530af2 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 8 Dec 2016 02:15:10 -0500 Subject: [PATCH] IR: better array len instruction reference the "len" field directly instead of looking it up by name since we already know exactly where the field metadata is --- src/ir.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ir.cpp b/src/ir.cpp index e4ca636ed9..f1df878f50 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -6572,8 +6572,7 @@ static TypeTableEntry *ir_analyze_instruction_array_len(IrAnalyze *ira, len_val->data.x_bignum.data.x_uint, depends_on_compile_var); } } - TypeStructField *field = find_struct_type_field(canon_type, buf_create_from_str("len")); - assert(field); + TypeStructField *field = &canon_type->data.structure.fields[slice_len_index]; IrInstruction *len_ptr = ir_build_struct_field_ptr(&ira->new_irb, array_len_instruction->base.scope, array_len_instruction->base.source_node, array_value, field); len_ptr->type_entry = get_pointer_to_type(ira->codegen, ira->codegen->builtin_types.entry_usize, true);