[llvm-commits] [llvm] r166045 - /llvm/trunk/lib/Transforms/Scalar/DCE.cpp
Jakub Staszak
kubastaszak at gmail.com
Tue Oct 16 12:32:31 PDT 2012
Author: kuba
Date: Tue Oct 16 14:32:31 2012
New Revision: 166045
URL: http://llvm.org/viewvc/llvm-project?rev=166045&view=rev
Log:
Simplify potentially quadratic behavior while erasing elements from std::vector.
Modified:
llvm/trunk/lib/Transforms/Scalar/DCE.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/DCE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DCE.cpp?rev=166045&r1=166044&r2=166045&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/DCE.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/DCE.cpp Tue Oct 16 14:32:31 2012
@@ -118,13 +118,7 @@
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;
More information about the llvm-commits
mailing list