inline repeats of constants
This commit is contained in:
parent
1ca0b3b9e6
commit
7c9e31f40b
1 changed files with 18 additions and 1 deletions
|
@ -1187,10 +1187,27 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Propagator<'ast, 'a, T> {
|
|||
TypedExpressionOrSpread::Spread(TypedSpread {
|
||||
array:
|
||||
ArrayExpression {
|
||||
ty: _,
|
||||
inner: ArrayExpressionInner::Value(v),
|
||||
..
|
||||
},
|
||||
}) => v.0,
|
||||
// simplify ...[a; N] to [a, ..., a] if a is constant
|
||||
TypedExpressionOrSpread::Spread(TypedSpread {
|
||||
array:
|
||||
ArrayExpression {
|
||||
inner:
|
||||
ArrayExpressionInner::Repeat(
|
||||
box v,
|
||||
box UExpression {
|
||||
inner: UExpressionInner::Value(count),
|
||||
..
|
||||
},
|
||||
),
|
||||
..
|
||||
},
|
||||
}) if is_constant(&v) => {
|
||||
vec![TypedExpressionOrSpread::Expression(v); count as usize]
|
||||
}
|
||||
e => vec![e],
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue