[TableGen] Use std::remove_if instead of an n^2 loop. NFC
authorCraig Topper <craig.topper@gmail.com>
Wed, 13 Jan 2016 07:20:10 +0000 (07:20 +0000)
committerCraig Topper <craig.topper@gmail.com>
Wed, 13 Jan 2016 07:20:10 +0000 (07:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257581 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/AsmWriterEmitter.cpp

index 1086424..a7fc7f3 100644 (file)
@@ -478,14 +478,11 @@ void AsmWriterEmitter::EmitPrintInstruction(raw_ostream &O) {
   }
 
   // Okay, delete instructions with no operand info left.
   }
 
   // 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
 
 
   // Because this is a vector, we want to emit from the end.  Reverse all of the