Chromium Code Reviews| Index: src/IceCfg.cpp |
| diff --git a/src/IceCfg.cpp b/src/IceCfg.cpp |
| index ab9d5f724e826babb9e60a9315faf5928ebd5a7c..a3b30eeeaf9016ee1a45d99ec18a19a05d1538d0 100644 |
| --- a/src/IceCfg.cpp |
| +++ b/src/IceCfg.cpp |
| @@ -148,7 +148,7 @@ void Cfg::reorderNodes() { |
| continue; |
| } |
| Node->setNeedsPlacement(false); |
| - if (Node != getEntryNode() && Node->getInEdges().size() == 0) { |
| + if (Node != getEntryNode() && Node->getInEdges().empty()) { |
| // The node has essentially been deleted since it is not a |
| // successor of any other node. |
| Unreachable.push_back(Node); |
| @@ -164,7 +164,7 @@ void Cfg::reorderNodes() { |
| // If it's a (non-critical) edge where the successor has a single |
| // in-edge, then place it before the successor. |
| - CfgNode *Succ = Node->getOutEdges()[0]; |
| + CfgNode *Succ = Node->getOutEdges().front(); |
| if (Succ->getInEdges().size() == 1 && |
| PlaceIndex[Succ->getIndex()] != NoPlace) { |
| Placed.insert(PlaceIndex[Succ->getIndex()], Node); |
| @@ -173,7 +173,7 @@ void Cfg::reorderNodes() { |
| } |
| // Otherwise, place it after the (first) predecessor. |
| - CfgNode *Pred = Node->getInEdges()[0]; |
| + CfgNode *Pred = Node->getInEdges().front(); |
| auto PredPosition = PlaceIndex[Pred->getIndex()]; |
| // It shouldn't be the case that PredPosition==NoPlace, but if |
| // that somehow turns out to be true, we just insert Node before |
| @@ -189,12 +189,14 @@ void Cfg::reorderNodes() { |
| } |
| // Reorder Nodes according to the built-up lists. |
| - SizeT Cur = 0; |
| + SizeT OldSize = Nodes.size(); |
|
Karl
2014/11/05 23:24:37
Note: One of the downsides to this is that size is
Jim Stichnoth
2014/11/05 23:39:45
In C++11, the complexity is constant.
|
| + (void)OldSize; |
|
Karl
2014/11/05 23:24:37
Why is this necessary?
Jim Stichnoth
2014/11/05 23:39:45
OldSize is only used in the assert, so otherwise y
|
| + Nodes.clear(); |
| for (CfgNode *Node : Placed) |
| - Nodes[Cur++] = Node; |
| + Nodes.push_back(Node); |
| for (CfgNode *Node : Unreachable) |
| - Nodes[Cur++] = Node; |
| - assert(Cur == Nodes.size()); |
| + Nodes.push_back(Node); |
| + assert(Nodes.size() == OldSize); |
| } |
| void Cfg::doArgLowering() { |