From ee28609e740504210a4208ee7bf49303dc851a46 Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Fri, 16 Sep 2022 09:37:17 -0700 Subject: [PATCH] script optimization fix for new-style table constructors --- src/script_opt/Expr.cc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/script_opt/Expr.cc b/src/script_opt/Expr.cc index d893431e66..20f39c640b 100644 --- a/src/script_opt/Expr.cc +++ b/src/script_opt/Expr.cc @@ -2009,8 +2009,21 @@ bool TableConstructorExpr::HasReducedOps(Reducer* c) const for ( const auto& expr : exprs ) { auto a = expr->AsAssignExpr(); + auto lhs = a->GetOp1(); + auto rhs = a->GetOp2(); + // 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); } @@ -2498,8 +2511,8 @@ bool ListExpr::HasReducedOps(Reducer* c) const { for ( const auto& expr : exprs ) { - // Ugly hack for record constructors. - if ( expr->Tag() == EXPR_FIELD_ASSIGN ) + // Ugly hack for record and complex table constructors. + if ( expr->Tag() == EXPR_FIELD_ASSIGN || expr->Tag() == EXPR_LIST ) { if ( ! expr->HasReducedOps(c) ) return false;