From 195aaaf5417ec535591a2286dc999a2f672b94c2 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 22 Mar 2018 06:15:10 +0000 Subject: [PATCH] [TableGen] Use empty emplace_back to add defaulted constructed objects to vectors to avoid using resize(size()+1). NFC llvm-svn: 328184 --- llvm/utils/TableGen/CodeGenSchedule.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/llvm/utils/TableGen/CodeGenSchedule.cpp b/llvm/utils/TableGen/CodeGenSchedule.cpp index 1f812fd..1b516c1 100644 --- a/llvm/utils/TableGen/CodeGenSchedule.cpp +++ b/llvm/utils/TableGen/CodeGenSchedule.cpp @@ -1312,7 +1312,7 @@ void PredTransitions::substituteVariants(const PredTransition &Trans) { // Build up a set of partial results starting at the back of // PredTransitions. Remember the first new transition. unsigned StartIdx = TransVec.size(); - TransVec.resize(TransVec.size() + 1); + TransVec.emplace_back(); TransVec.back().PredTerm = Trans.PredTerm; TransVec.back().ProcIndices = Trans.ProcIndices; @@ -1323,7 +1323,7 @@ void PredTransitions::substituteVariants(const PredTransition &Trans) { // Push a new (empty) write sequence onto all partial Transitions. for (std::vector::iterator I = TransVec.begin() + StartIdx, E = TransVec.end(); I != E; ++I) { - I->WriteSequences.resize(I->WriteSequences.size() + 1); + I->WriteSequences.emplace_back(); } substituteVariantOperand(*WSI, /*IsRead=*/false, StartIdx); } @@ -1334,7 +1334,7 @@ void PredTransitions::substituteVariants(const PredTransition &Trans) { // Push a new (empty) read sequence onto all partial Transitions. for (std::vector::iterator I = TransVec.begin() + StartIdx, E = TransVec.end(); I != E; ++I) { - I->ReadSequences.resize(I->ReadSequences.size() + 1); + I->ReadSequences.emplace_back(); } substituteVariantOperand(*RSI, /*IsRead=*/true, StartIdx); } @@ -1388,16 +1388,15 @@ void CodeGenSchedModels::inferFromRW(ArrayRef OperWrites, // Create a seed transition with an empty PredTerm and the expanded sequences // of SchedWrites for the current SchedClass. std::vector LastTransitions; - LastTransitions.resize(1); + LastTransitions.emplace_back(); LastTransitions.back().ProcIndices.append(ProcIndices.begin(), ProcIndices.end()); for (unsigned WriteIdx : OperWrites) { IdxVec WriteSeq; expandRWSequence(WriteIdx, WriteSeq, /*IsRead=*/false); - unsigned Idx = LastTransitions[0].WriteSequences.size(); - LastTransitions[0].WriteSequences.resize(Idx + 1); - SmallVectorImpl &Seq = LastTransitions[0].WriteSequences[Idx]; + LastTransitions[0].WriteSequences.emplace_back(); + SmallVectorImpl &Seq = LastTransitions[0].WriteSequences.back(); Seq.append(WriteSeq.begin(), WriteSeq.end()); DEBUG(dbgs() << "("; dumpIdxVec(Seq); dbgs() << ") "); } @@ -1405,9 +1404,8 @@ void CodeGenSchedModels::inferFromRW(ArrayRef OperWrites, for (unsigned ReadIdx : OperReads) { IdxVec ReadSeq; expandRWSequence(ReadIdx, ReadSeq, /*IsRead=*/true); - unsigned Idx = LastTransitions[0].ReadSequences.size(); - LastTransitions[0].ReadSequences.resize(Idx + 1); - SmallVectorImpl &Seq = LastTransitions[0].ReadSequences[Idx]; + LastTransitions[0].ReadSequences.emplace_back(); + SmallVectorImpl &Seq = LastTransitions[0].ReadSequences.back(); Seq.append(ReadSeq.begin(), ReadSeq.end()); DEBUG(dbgs() << "("; dumpIdxVec(Seq); dbgs() << ") "); } -- 2.7.4