mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-31 18:32:12 +00:00
Add minor ignoring hint on type assertions to get better code generation with no optimizations enabled
This commit is contained in:
@@ -3949,6 +3949,16 @@ bool check_assignment_arguments(CheckerContext *ctx, Array<Operand> const &lhs,
|
||||
add_type_and_value(&c->checker->info, o.expr, o.mode, tuple, o.value);
|
||||
}
|
||||
|
||||
if (o.mode == Addressing_OptionalOk && expr->kind == Ast_TypeAssertion) {
|
||||
// NOTE(bill): Used only for optimizations in the backend
|
||||
if (is_blank_ident(lhs[0].expr)) {
|
||||
expr->TypeAssertion.ignores[0] = true;
|
||||
}
|
||||
if (is_blank_ident(lhs[1].expr)) {
|
||||
expr->TypeAssertion.ignores[1] = true;
|
||||
}
|
||||
}
|
||||
|
||||
array_add(operands, val0);
|
||||
array_add(operands, val1);
|
||||
optional_ok = true;
|
||||
@@ -4063,6 +4073,16 @@ bool check_unpack_arguments(CheckerContext *ctx, Entity **lhs, isize lhs_count,
|
||||
add_type_and_value(&c->checker->info, o.expr, o.mode, tuple, o.value);
|
||||
}
|
||||
|
||||
if (o.mode == Addressing_OptionalOk && expr->kind == Ast_TypeAssertion) {
|
||||
// NOTE(bill): Used only for optimizations in the backend
|
||||
if (is_blank_ident(lhs[0]->token)) {
|
||||
expr->TypeAssertion.ignores[0] = true;
|
||||
}
|
||||
if (is_blank_ident(lhs[1]->token)) {
|
||||
expr->TypeAssertion.ignores[1] = true;
|
||||
}
|
||||
}
|
||||
|
||||
array_add(operands, val0);
|
||||
array_add(operands, val1);
|
||||
optional_ok = true;
|
||||
|
||||
Reference in New Issue
Block a user