diff --git a/src/Expr.h b/src/Expr.h index d93d51597b..d662807b07 100644 --- a/src/Expr.h +++ b/src/Expr.h @@ -1135,7 +1135,7 @@ private: class InlineExpr : public Expr { public: - InlineExpr(ListExprPtr arg_args, IDPList* params, StmtPtr body, + InlineExpr(ListExprPtr arg_args, std::vector params, StmtPtr body, int frame_offset, TypePtr ret_type); bool IsPure() const override; @@ -1152,7 +1152,7 @@ public: protected: void ExprDescribe(ODesc* d) const override; - IDPList* params; + std::vector params; int frame_offset; ListExprPtr args; StmtPtr body; diff --git a/src/script_opt/Expr.cc b/src/script_opt/Expr.cc index bcb8043284..9106da8358 100644 --- a/src/script_opt/Expr.cc +++ b/src/script_opt/Expr.cc @@ -445,13 +445,13 @@ ExprPtr IsExpr::Duplicate() } -InlineExpr::InlineExpr(ListExprPtr arg_args, IDPList* arg_params, +InlineExpr::InlineExpr(ListExprPtr arg_args, std::vector arg_params, StmtPtr arg_body, int _frame_offset, TypePtr ret_type) : Expr(EXPR_INLINE), args(std::move(arg_args)), body(std::move(arg_body)) { - params = arg_params; + params = std::move(arg_params); frame_offset = _frame_offset; - type = ret_type; + type = std::move(ret_type); } bool InlineExpr::IsPure() const @@ -497,8 +497,7 @@ ExprPtr InlineExpr::Duplicate() { auto args_d = args->Duplicate()->AsListExprPtr(); auto body_d = body->Duplicate(); - return SetSucc(new InlineExpr(args_d, params, body_d, frame_offset, - type)); + return SetSucc(new InlineExpr(args_d, params, body_d, frame_offset, type)); } TraversalCode InlineExpr::Traverse(TraversalCallback* cb) const diff --git a/src/script_opt/Inline.cc b/src/script_opt/Inline.cc index fdd0c8ec11..a73d9220d2 100644 --- a/src/script_opt/Inline.cc +++ b/src/script_opt/Inline.cc @@ -199,12 +199,14 @@ ExprPtr Inliner::CheckForInlining(IntrusivePtr c) // the function, *using the knowledge that the parameters are // declared first*. auto scope = func_vf->GetScope(); - auto vars = scope->OrderedVars(); + auto& vars = scope->OrderedVars(); int nparam = func_vf->GetType()->Params()->NumFields(); - auto params = new IDPList; + std::vector params; + params.reserve(nparam); + for ( int i = 0; i < nparam; ++i ) - params->append(vars[i].get()); + params.emplace_back(vars[i]); auto body_dup = body->Duplicate(); @@ -229,8 +231,8 @@ ExprPtr Inliner::CheckForInlining(IntrusivePtr c) else max_inlined_frame_size = hold_max_inlined_frame_size; - auto ie = make_intrusive(args, params, body_dup, - curr_frame_size, t); + auto ie = make_intrusive(args, std::move(params), body_dup, + curr_frame_size, t); ie->SetOriginal(c); return ie;