[llvm] r230863 - LiveRange: Replace a creative vector erase loop with std::remove_if.
Benjamin Kramer
benny.kra at googlemail.com
Sat Feb 28 12:14:27 PST 2015
Author: d0k
Date: Sat Feb 28 14:14:27 2015
New Revision: 230863
URL: http://llvm.org/viewvc/llvm-project?rev=230863&view=rev
Log:
LiveRange: Replace a creative vector erase loop with std::remove_if.
I didn't see this so far because it scans backwards, but that doesn't
make it any less quadratic. NFC.
Modified:
llvm/trunk/lib/CodeGen/LiveInterval.cpp
Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=230863&r1=230862&r2=230863&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Sat Feb 28 14:14:27 2015
@@ -567,13 +567,9 @@ void LiveRange::removeSegment(SlotIndex
/// Also remove the value# from value# list.
void LiveRange::removeValNo(VNInfo *ValNo) {
if (empty()) return;
- iterator I = end();
- iterator E = begin();
- do {
- --I;
- if (I->valno == ValNo)
- segments.erase(I);
- } while (I != E);
+ segments.erase(std::remove_if(begin(), end(), [ValNo](const Segment &S) {
+ return S.valno == ValNo;
+ }), end());
// Now that ValNo is dead, remove it.
markValNoForDeletion(ValNo);
}
More information about the llvm-commits
mailing list