mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
Simplify potentially quadratic behavior while erasing elements from std::vector.
llvm-svn: 166045
This commit is contained in:
parent
235be85221
commit
3eeb051e40
@ -118,13 +118,7 @@ bool DCE::runOnFunction(Function &F) {
|
||||
I->eraseFromParent();
|
||||
|
||||
// Remove the instruction from the worklist if it still exists in it.
|
||||
for (std::vector<Instruction*>::iterator WI = WorkList.begin();
|
||||
WI != WorkList.end(); ) {
|
||||
if (*WI == I)
|
||||
WI = WorkList.erase(WI);
|
||||
else
|
||||
++WI;
|
||||
}
|
||||
WorkList.erase(std::remove(WorkList.begin(), WorkList.end(), I), WorkList.end());
|
||||
|
||||
MadeChange = true;
|
||||
++DCEEliminated;
|
||||
|
Loading…
Reference in New Issue
Block a user