[llvm] r257581 - [TableGen] Use std::remove_if instead of an n^2 loop. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 12 23:20:10 PST 2016
Author: ctopper
Date: Wed Jan 13 01:20:10 2016
New Revision: 257581
URL: http://llvm.org/viewvc/llvm-project?rev=257581&view=rev
Log:
[TableGen] Use std::remove_if instead of an n^2 loop. NFC
Modified:
llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp
Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp?rev=257581&r1=257580&r2=257581&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Wed Jan 13 01:20:10 2016
@@ -478,14 +478,11 @@ void AsmWriterEmitter::EmitPrintInstruct
}
// Okay, delete instructions with no operand info left.
- for (unsigned i = 0, e = Instructions.size(); i != e; ++i) {
- // Entire instruction has been emitted?
- AsmWriterInst &Inst = Instructions[i];
- if (Inst.Operands.empty()) {
- Instructions.erase(Instructions.begin()+i);
- --i; --e;
- }
- }
+ auto I = std::remove_if(Instructions.begin(), Instructions.end(),
+ [](AsmWriterInst &Inst) {
+ return Inst.Operands.empty();
+ });
+ Instructions.erase(I, Instructions.end());
// Because this is a vector, we want to emit from the end. Reverse all of the
More information about the llvm-commits
mailing list