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

ast.table: optimize get_final_type_symbol() (#10646)

This commit is contained in:
yuyi 2021-07-02 21:59:41 +08:00 committed by GitHub
parent 1486258591
commit 8628b19a3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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] }
}