From 8628b19a3ab08cc767930cd9c3f4668406c07b77 Mon Sep 17 00:00:00 2001 From: yuyi Date: Fri, 2 Jul 2021 21:59:41 +0800 Subject: [PATCH] ast.table: optimize get_final_type_symbol() (#10646) --- vlib/v/ast/table.v | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/vlib/v/ast/table.v b/vlib/v/ast/table.v index 93562e38d5..eab34d50e0 100644 --- a/vlib/v/ast/table.v +++ b/vlib/v/ast/table.v @@ -496,7 +496,6 @@ pub const invalid_type_symbol = &TypeSymbol{ [inline] pub fn (t &Table) get_type_symbol(typ Type) &TypeSymbol { - // println('get_type_symbol $typ') idx := typ.idx() if idx > 0 { return unsafe { &t.type_symbols[idx] } @@ -510,12 +509,11 @@ pub fn (t &Table) get_type_symbol(typ Type) &TypeSymbol { // get_final_type_symbol follows aliases until it gets to a "real" Type [inline] pub fn (t &Table) get_final_type_symbol(typ Type) &TypeSymbol { - idx := typ.idx() + mut idx := typ.idx() if idx > 0 { current_type := t.type_symbols[idx] if current_type.kind == .alias { - alias_info := current_type.info as Alias - return t.get_final_type_symbol(alias_info.parent_type) + idx = (current_type.info as Alias).parent_type.idx() } return unsafe { &t.type_symbols[idx] } }