Skip to content

Commit

Permalink
Replace stack by deque and use range-based for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen Jones committed Apr 20, 2018
1 parent 987edbe commit 4840154
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/linking/linking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1185,25 +1185,20 @@ void linkingt::do_type_dependencies(
}
}

std::stack<irep_idt> queue;

for(std::unordered_set<irep_idt>::const_iterator d_it =
needs_to_be_renamed.begin();
d_it != needs_to_be_renamed.end();
d_it++)
queue.push(*d_it);
std::deque<irep_idt> queue(
needs_to_be_renamed.begin(), needs_to_be_renamed.end());

while(!queue.empty())
{
irep_idt id = queue.top();
queue.pop();
irep_idt id = queue.back();
queue.pop_back();

const std::unordered_set<irep_idt> &u = used_by[id];

for(const auto &dep : u)
if(needs_to_be_renamed.insert(dep).second)
{
queue.push(dep);
queue.push_back(dep);
#ifdef DEBUG
debug() << "LINKING: needs to be renamed (dependency): "
<< dep << eom;
Expand Down

0 comments on commit 4840154

Please sign in to comment.