From 0d19e8fb4c21ee01d4e3ecfde950b88e5803a4db Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Wed, 27 May 2020 17:30:28 -0700 Subject: [PATCH] Add version of Frame::SetElement() taking IntrusivePtr Expect the version using raw ID* could go away eventually, but this is convenience for the meantime. --- src/Expr.cc | 2 +- src/Frame.h | 2 ++ src/Stmt.cc | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Expr.cc b/src/Expr.cc index fd53c31ede..eadefb59d9 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -273,7 +273,7 @@ void NameExpr::Assign(Frame* f, IntrusivePtr v) if ( id->IsGlobal() ) id->SetVal(std::move(v)); else - f->SetElement(id.get(), std::move(v)); + f->SetElement(id, std::move(v)); } bool NameExpr::IsPure() const diff --git a/src/Frame.h b/src/Frame.h index 6dc3a055c5..a85254469c 100644 --- a/src/Frame.h +++ b/src/Frame.h @@ -66,6 +66,8 @@ public: * @param v the value to associate it with */ void SetElement(const ID* id, IntrusivePtr v); + void SetElement(const IntrusivePtr& id, IntrusivePtr v) + { SetElement(id.get(), std::move(v)); } /** * Gets the value associated with *id* and returns it. Returns diff --git a/src/Stmt.cc b/src/Stmt.cc index 85ba3d4ec3..60b93f1201 100644 --- a/src/Stmt.cc +++ b/src/Stmt.cc @@ -1191,7 +1191,7 @@ IntrusivePtr ForStmt::DoExec(Frame* f, Val* v, stmt_flow_type& flow) const delete k; if ( value_var ) - f->SetElement(value_var.get(), current_tev->GetVal()); + f->SetElement(value_var, current_tev->GetVal()); for ( int i = 0; i < ind_lv->Length(); i++ ) f->SetElement((*loop_vars)[i], ind_lv->Idx(i)); @@ -1663,7 +1663,7 @@ IntrusivePtr InitStmt::Exec(Frame* f, stmt_flow_type& flow) const break; } - f->SetElement(aggr.get(), std::move(v)); + f->SetElement(aggr, std::move(v)); } return nullptr;