mirror of
https://github.com/vlang/v.git
synced 2025-09-14 09:56:16 -04:00
checker: reduce table.sym() calls in infix expression checks (#22476)
This commit is contained in:
parent
7cdd667740
commit
1a145bfff3
@ -306,15 +306,13 @@ fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type {
|
||||
right_sym = c.table.sym(unwrapped_right_type)
|
||||
if mut right_sym.info is ast.Alias && (right_sym.info.language != .c
|
||||
&& c.mod == c.table.type_to_str(unwrapped_right_type).split('.')[0]
|
||||
&& (c.table.sym(right_sym.info.parent_type).is_primitive()
|
||||
|| c.table.sym(right_sym.info.parent_type).kind == .enum)) {
|
||||
right_sym = c.table.sym(right_sym.info.parent_type)
|
||||
&& (right_final_sym.is_primitive() || right_final_sym.kind == .enum)) {
|
||||
right_sym = right_final_sym
|
||||
}
|
||||
if mut left_sym.info is ast.Alias && (left_sym.info.language != .c
|
||||
&& c.mod == c.table.type_to_str(unwrapped_left_type).split('.')[0]
|
||||
&& (c.table.sym(left_sym.info.parent_type).is_primitive()
|
||||
|| c.table.sym(left_sym.info.parent_type).kind == .enum)) {
|
||||
left_sym = c.table.sym(left_sym.info.parent_type)
|
||||
&& (left_final_sym.is_primitive() || left_final_sym.kind == .enum)) {
|
||||
left_sym = left_final_sym
|
||||
}
|
||||
|
||||
if c.pref.translated && node.op in [.plus, .minus, .mul]
|
||||
@ -322,7 +320,7 @@ fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type {
|
||||
&& unwrapped_right_type.is_any_kind_of_pointer() {
|
||||
return_type = left_type
|
||||
} else if !c.pref.translated && left_sym.info is ast.Alias
|
||||
&& !(c.table.sym(left_sym.info.parent_type).is_primitive()) {
|
||||
&& !left_final_sym.is_primitive() {
|
||||
if left_sym.has_method(node.op.str()) {
|
||||
if method := left_sym.find_method(node.op.str()) {
|
||||
return_type = method.return_type
|
||||
@ -347,7 +345,7 @@ fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type {
|
||||
}
|
||||
}
|
||||
} else if !c.pref.translated && right_sym.info is ast.Alias
|
||||
&& !(c.table.sym(right_sym.info.parent_type).is_primitive()) {
|
||||
&& !right_final_sym.is_primitive() {
|
||||
if right_sym.has_method(node.op.str()) {
|
||||
if method := right_sym.find_method(node.op.str()) {
|
||||
return_type = method.return_type
|
||||
@ -477,15 +475,13 @@ fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type {
|
||||
|
||||
left_sym = c.table.sym(unwrapped_left_type)
|
||||
right_sym = c.table.sym(unwrapped_right_type)
|
||||
if left_sym.info is ast.Alias
|
||||
&& c.table.sym(left_sym.info.parent_type).is_primitive() {
|
||||
if left_sym.info is ast.Alias && left_final_sym.is_primitive() {
|
||||
if left_sym.has_method(node.op.str()) {
|
||||
if method := left_sym.find_method(node.op.str()) {
|
||||
return_type = method.return_type
|
||||
}
|
||||
}
|
||||
} else if right_sym.info is ast.Alias
|
||||
&& c.table.sym(right_sym.info.parent_type).is_primitive() {
|
||||
} else if right_sym.info is ast.Alias && right_final_sym.is_primitive() {
|
||||
if right_sym.has_method(node.op.str()) {
|
||||
if method := right_sym.find_method(node.op.str()) {
|
||||
return_type = method.return_type
|
||||
|
Loading…
x
Reference in New Issue
Block a user