Adjust reference/move nitpicks in use-def/reduce code

Use std::move() and avoid superfluous copies by assigning to
const-reference in a few places.
This commit is contained in:
Jon Siwek 2021-02-08 17:50:57 -08:00
parent 8d452f58fc
commit b450b90a3e
3 changed files with 5 additions and 5 deletions

View file

@ -108,7 +108,7 @@ public:
// Tells the reducer to replace the given statement during the
// next reduction pass.
void AddStmtToReplace(const Stmt* s_old, StmtPtr s_new)
{ replaced_stmts[s_old] = s_new; }
{ replaced_stmts[s_old] = std::move(s_new); }
// Tells the reducer that it can reclaim the storage associated
// with the omitted statements.

View file

@ -194,7 +194,7 @@ UDs UseDefs::PropagateUDs(const Stmt* s, UDs succ_UDs,
case STMT_LIST:
{
auto sl = s->AsStmtList();
auto stmts = sl->Stmts();
const auto& stmts = sl->Stmts();
for ( int i = stmts.length(); --i >= 0; )
{
@ -396,7 +396,7 @@ UDs UseDefs::PropagateUDs(const Stmt* s, UDs succ_UDs,
successor2[body.get()] = succ_stmt;
auto body_UDs = PropagateUDs(body.get(), succ_UDs, succ.get(), second_pass);
auto cond = w->Condition();
const auto& cond = w->Condition();
auto w_UDs = UD_Union(ExprUDs(cond.get()), body_UDs);
FoldInUDs(w_UDs, body_UDs);
@ -404,7 +404,7 @@ UDs UseDefs::PropagateUDs(const Stmt* s, UDs succ_UDs,
{
// Create a successor for the cond_stmt
// that has the correct UDs associated with it.
auto c_as_s = w->ConditionAsStmt();
const auto& c_as_s = w->ConditionAsStmt();
auto c_as_s_UDs = std::make_shared<UseDefSet>(w_UDs);
CreateUDs(c_as_s.get(), c_as_s_UDs);

View file

@ -95,7 +95,7 @@ private:
UDs PropagateUDs(const StmtPtr& s, UDs succ_UDs,
const StmtPtr& succ_stmt, bool second_pass)
{
return PropagateUDs(s.get(), succ_UDs, succ_stmt.get(),
return PropagateUDs(s.get(), std::move(succ_UDs), succ_stmt.get(),
second_pass);
}
UDs PropagateUDs(const Stmt* s, UDs succ_UDs,