1
0
Fork 0
mirror of synced 2025-09-23 12:18:44 +00:00

inline repeats of constants

This commit is contained in:
schaeff 2021-08-04 21:20:45 +02:00
parent 1ca0b3b9e6
commit 7c9e31f40b

View file

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