diff options
author | Jakub Staszak <kubastaszak@gmail.com> | 2012-10-16 19:32:31 +0000 |
---|---|---|
committer | Jakub Staszak <kubastaszak@gmail.com> | 2012-10-16 19:32:31 +0000 |
commit | 761fbec9c2ace70c12cf41f5d0e97c42a303eeb9 (patch) | |
tree | 572bdb9e80a364b89b656facfb93a6d1a3b9d0d5 /lib/Transforms/Scalar | |
parent | 79b319d35589ffe9c00a5e112a79ad20ea78c4d5 (diff) | |
download | external_llvm-761fbec9c2ace70c12cf41f5d0e97c42a303eeb9.zip external_llvm-761fbec9c2ace70c12cf41f5d0e97c42a303eeb9.tar.gz external_llvm-761fbec9c2ace70c12cf41f5d0e97c42a303eeb9.tar.bz2 |
Simplify potentially quadratic behavior while erasing elements from std::vector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166045 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r-- | lib/Transforms/Scalar/DCE.cpp | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp index 086f0a1..8d53443 100644 --- a/lib/Transforms/Scalar/DCE.cpp +++ b/lib/Transforms/Scalar/DCE.cpp @@ -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; |