script optimization fix for new-style table constructors

This commit is contained in:
Vern Paxson 2022-09-16 09:37:17 -07:00
parent 5389ad69f8
commit ee28609e74

View file

@ -2009,8 +2009,21 @@ bool TableConstructorExpr::HasReducedOps(Reducer* c) const
for ( const auto& expr : exprs ) for ( const auto& expr : exprs )
{ {
auto a = expr->AsAssignExpr(); auto a = expr->AsAssignExpr();
auto lhs = a->GetOp1();
auto rhs = a->GetOp2();
// LHS is a list, not a singleton. // LHS is a list, not a singleton.
if ( ! a->GetOp1()->HasReducedOps(c) || ! a->GetOp2()->IsSingleton(c) ) if ( ! lhs->HasReducedOps(c) )
return NonReduced(this);
// RHS might also be a list, if it's a table-of-sets or such.
if ( rhs->Tag() == EXPR_LIST )
{
if ( ! rhs->HasReducedOps(c) )
return NonReduced(this);
}
else if ( ! rhs->IsSingleton(c) )
return NonReduced(this); return NonReduced(this);
} }
@ -2498,8 +2511,8 @@ bool ListExpr::HasReducedOps(Reducer* c) const
{ {
for ( const auto& expr : exprs ) for ( const auto& expr : exprs )
{ {
// Ugly hack for record constructors. // Ugly hack for record and complex table constructors.
if ( expr->Tag() == EXPR_FIELD_ASSIGN ) if ( expr->Tag() == EXPR_FIELD_ASSIGN || expr->Tag() == EXPR_LIST )
{ {
if ( ! expr->HasReducedOps(c) ) if ( ! expr->HasReducedOps(c) )
return false; return false;