[llvm] r328033 - [TableGen] Use vector::append instead of looping and calling push_back. NFC

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 20 13:24:15 PDT 2018


Author: ctopper
Date: Tue Mar 20 13:24:14 2018
New Revision: 328033

URL: http://llvm.org/viewvc/llvm-project?rev=328033&view=rev
Log:
[TableGen] Use vector::append instead of looping and calling push_back. NFC

Both vectors contain unsigned so we can just use append to do the copying. Not only is this shorter, but it should be able to predict the final size and only grow the vector once if needed.

Modified:
    llvm/trunk/utils/TableGen/CodeGenSchedule.cpp

Modified: llvm/trunk/utils/TableGen/CodeGenSchedule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenSchedule.cpp?rev=328033&r1=328032&r2=328033&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenSchedule.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenSchedule.cpp Tue Mar 20 13:24:14 2018
@@ -1420,8 +1420,7 @@ void CodeGenSchedModels::inferFromRW(Arr
     unsigned Idx = LastTransitions[0].WriteSequences.size();
     LastTransitions[0].WriteSequences.resize(Idx + 1);
     SmallVectorImpl<unsigned> &Seq = LastTransitions[0].WriteSequences[Idx];
-    for (IdxIter WI = WriteSeq.begin(), WE = WriteSeq.end(); WI != WE; ++WI)
-      Seq.push_back(*WI);
+    Seq.append(WriteSeq.begin(), WriteSeq.end());
     DEBUG(dbgs() << "("; dumpIdxVec(Seq); dbgs() << ") ");
   }
   DEBUG(dbgs() << " Reads: ");
@@ -1431,8 +1430,7 @@ void CodeGenSchedModels::inferFromRW(Arr
     unsigned Idx = LastTransitions[0].ReadSequences.size();
     LastTransitions[0].ReadSequences.resize(Idx + 1);
     SmallVectorImpl<unsigned> &Seq = LastTransitions[0].ReadSequences[Idx];
-    for (IdxIter RI = ReadSeq.begin(), RE = ReadSeq.end(); RI != RE; ++RI)
-      Seq.push_back(*RI);
+    Seq.append(ReadSeq.begin(), ReadSeq.end());
     DEBUG(dbgs() << "("; dumpIdxVec(Seq); dbgs() << ") ");
   }
   DEBUG(dbgs() << '\n');




More information about the llvm-commits mailing list