mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
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:
parent
8d452f58fc
commit
b450b90a3e
3 changed files with 5 additions and 5 deletions
|
@ -108,7 +108,7 @@ public:
|
||||||
// Tells the reducer to replace the given statement during the
|
// Tells the reducer to replace the given statement during the
|
||||||
// next reduction pass.
|
// next reduction pass.
|
||||||
void AddStmtToReplace(const Stmt* s_old, StmtPtr s_new)
|
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
|
// Tells the reducer that it can reclaim the storage associated
|
||||||
// with the omitted statements.
|
// with the omitted statements.
|
||||||
|
|
|
@ -194,7 +194,7 @@ UDs UseDefs::PropagateUDs(const Stmt* s, UDs succ_UDs,
|
||||||
case STMT_LIST:
|
case STMT_LIST:
|
||||||
{
|
{
|
||||||
auto sl = s->AsStmtList();
|
auto sl = s->AsStmtList();
|
||||||
auto stmts = sl->Stmts();
|
const auto& stmts = sl->Stmts();
|
||||||
|
|
||||||
for ( int i = stmts.length(); --i >= 0; )
|
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;
|
successor2[body.get()] = succ_stmt;
|
||||||
auto body_UDs = PropagateUDs(body.get(), succ_UDs, succ.get(), second_pass);
|
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);
|
auto w_UDs = UD_Union(ExprUDs(cond.get()), body_UDs);
|
||||||
FoldInUDs(w_UDs, 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
|
// Create a successor for the cond_stmt
|
||||||
// that has the correct UDs associated with it.
|
// 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);
|
auto c_as_s_UDs = std::make_shared<UseDefSet>(w_UDs);
|
||||||
CreateUDs(c_as_s.get(), c_as_s_UDs);
|
CreateUDs(c_as_s.get(), c_as_s_UDs);
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ private:
|
||||||
UDs PropagateUDs(const StmtPtr& s, UDs succ_UDs,
|
UDs PropagateUDs(const StmtPtr& s, UDs succ_UDs,
|
||||||
const StmtPtr& succ_stmt, bool second_pass)
|
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);
|
second_pass);
|
||||||
}
|
}
|
||||||
UDs PropagateUDs(const Stmt* s, UDs succ_UDs,
|
UDs PropagateUDs(const Stmt* s, UDs succ_UDs,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue