Tooling: Move heavyweight vectors around instead of copying.
While there convert to range-based for loops. No functionality change.
llvm-svn: 204338
diff --git a/clang/tools/libclang/CXCompilationDatabase.cpp b/clang/tools/libclang/CXCompilationDatabase.cpp
index 156a3e2..f4728fe 100644
--- a/clang/tools/libclang/CXCompilationDatabase.cpp
+++ b/clang/tools/libclang/CXCompilationDatabase.cpp
@@ -40,9 +40,8 @@
{
std::vector<CompileCommand> CCmd;
- AllocatedCXCompileCommands(const std::vector<CompileCommand>& Cmd)
- : CCmd(Cmd)
- { }
+ AllocatedCXCompileCommands(std::vector<CompileCommand> Cmd)
+ : CCmd(std::move(Cmd)) {}
};
CXCompileCommands
@@ -50,10 +49,9 @@
const char *CompleteFileName)
{
if (CompilationDatabase *db = static_cast<CompilationDatabase *>(CDb)) {
- const std::vector<CompileCommand>
- CCmd(db->getCompileCommands(CompleteFileName));
+ std::vector<CompileCommand> CCmd(db->getCompileCommands(CompleteFileName));
if (!CCmd.empty())
- return new AllocatedCXCompileCommands( CCmd );
+ return new AllocatedCXCompileCommands(std::move(CCmd));
}
return 0;
@@ -62,9 +60,9 @@
CXCompileCommands
clang_CompilationDatabase_getAllCompileCommands(CXCompilationDatabase CDb) {
if (CompilationDatabase *db = static_cast<CompilationDatabase *>(CDb)) {
- const std::vector<CompileCommand> CCmd(db->getAllCompileCommands());
+ std::vector<CompileCommand> CCmd(db->getAllCompileCommands());
if (!CCmd.empty())
- return new AllocatedCXCompileCommands( CCmd );
+ return new AllocatedCXCompileCommands(std::move(CCmd));
}
return 0;