push_back() loop -> append() for random access iterators.

append will resize the vector to the optimal size. No functional change
intended.

llvm-svn: 239607
This commit is contained in:
Benjamin Kramer 2015-06-12 15:31:50 +00:00
parent 133aa20e22
commit f367dd90cc
8 changed files with 13 additions and 38 deletions

View File

@ -75,11 +75,7 @@ class Parser {
return;
MoreLATokens.push_back(Tok);
for (const Token *I = &Toks.back(),
*B = &Toks.front();
I != B; --I) {
MoreLATokens.push_back(*I);
}
MoreLATokens.append(Toks.rbegin(), std::prev(Toks.rend()));
Tok = Toks[0];
}

View File

@ -531,10 +531,7 @@ bool RecursiveASTVisitor<Derived>::TraverseStmt(Stmt *S) {
}
}
for (SmallVectorImpl<Stmt *>::reverse_iterator RI = StmtsToEnqueue.rbegin(),
RE = StmtsToEnqueue.rend();
RI != RE; ++RI)
Queue.push_back(*RI);
Queue.append(StmtsToEnqueue.rbegin(), StmtsToEnqueue.rend());
}
return true;

View File

@ -455,8 +455,9 @@ class Preprocessor : public RefCountedBase<Preprocessor> {
void overrideActiveModuleMacros(Preprocessor &PP, IdentifierInfo *II) {
if (auto *Info = getModuleInfo(PP, II)) {
for (auto *Active : Info->ActiveModuleMacros)
Info->OverriddenMacros.push_back(Active);
Info->OverriddenMacros.insert(Info->OverriddenMacros.end(),
Info->ActiveModuleMacros.begin(),
Info->ActiveModuleMacros.end());
Info->ActiveModuleMacros.clear();
Info->IsAmbiguous = false;
}

View File

@ -321,18 +321,10 @@ void DiagnosticsEngine::Report(const StoredDiagnostic &storedDiag) {
NumDiagArgs = 0;
DiagRanges.clear();
DiagRanges.reserve(storedDiag.range_size());
for (StoredDiagnostic::range_iterator
RI = storedDiag.range_begin(),
RE = storedDiag.range_end(); RI != RE; ++RI)
DiagRanges.push_back(*RI);
DiagRanges.append(storedDiag.range_begin(), storedDiag.range_end());
DiagFixItHints.clear();
DiagFixItHints.reserve(storedDiag.fixit_size());
for (StoredDiagnostic::fixit_iterator
FI = storedDiag.fixit_begin(),
FE = storedDiag.fixit_end(); FI != FE; ++FI)
DiagFixItHints.push_back(*FI);
DiagFixItHints.append(storedDiag.fixit_begin(), storedDiag.fixit_end());
assert(Client && "DiagnosticConsumer not set!");
Level DiagLevel = storedDiag.getLevel();

View File

@ -2996,13 +2996,9 @@ CodeGenFunction::GenerateObjCAtomicGetterCopyHelperFunction(
SmallVector<Expr*, 4> ConstructorArgs;
ConstructorArgs.push_back(&SRC);
CXXConstructExpr::arg_iterator A = CXXConstExpr->arg_begin();
++A;
for (CXXConstructExpr::arg_iterator AEnd = CXXConstExpr->arg_end();
A != AEnd; ++A)
ConstructorArgs.push_back(*A);
ConstructorArgs.append(std::next(CXXConstExpr->arg_begin()),
CXXConstExpr->arg_end());
CXXConstructExpr *TheCXXConstructExpr =
CXXConstructExpr::Create(C, Ty, SourceLocation(),
CXXConstExpr->getConstructor(),

View File

@ -722,11 +722,7 @@ void Sema::ActOnEndOfTranslationUnit() {
ModMap.resolveConflicts(Mod, /*Complain=*/false);
// Queue the submodules, so their exports will also be resolved.
for (Module::submodule_iterator Sub = Mod->submodule_begin(),
SubEnd = Mod->submodule_end();
Sub != SubEnd; ++Sub) {
Stack.push_back(*Sub);
}
Stack.append(Mod->submodule_begin(), Mod->submodule_end());
}
}

View File

@ -190,8 +190,7 @@ namespace clang {
assert(D->isCanonicalDecl() && "non-canonical decl in set");
Writer.AddDeclRef(D, Record);
}
for (DeclID ID : LazySpecializations)
Record.push_back(ID);
Record.append(LazySpecializations.begin(), LazySpecializations.end());
}
};
}

View File

@ -101,9 +101,7 @@ CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
}
TextDiagnosticBuffer diagBuffer;
SmallVector<StringRef, 32> Files;
for (unsigned i = 0; i != numFiles; ++i)
Files.push_back(filePaths[i]);
SmallVector<StringRef, 32> Files(filePaths, filePaths + numFiles);
bool err = arcmt::getFileRemappingsFromFileList(remap->Vec, Files,
&diagBuffer);