mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-03 10:23:32 +00:00
const propagation: simplyfy struct access
so that `{ min: 10px, max: 20px }.min` get optimized
This commit is contained in:
parent
8f52015fe5
commit
b180661ff6
1 changed files with 9 additions and 0 deletions
|
@ -99,6 +99,15 @@ fn simplify_expression(expr: &mut Expression) -> bool {
|
|||
}
|
||||
can_inline
|
||||
}
|
||||
Expression::StructFieldAccess { base, name } => {
|
||||
if let Expression::Struct { values, .. } = &mut **base {
|
||||
if let Some(e) = values.remove(name) {
|
||||
*expr = e;
|
||||
return simplify_expression(expr);
|
||||
}
|
||||
};
|
||||
simplify_expression(base)
|
||||
}
|
||||
Expression::Cast { from, to } => {
|
||||
let can_inline = simplify_expression(from);
|
||||
let new = if from.ty() == *to {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue