summaryrefslogtreecommitdiff
path: root/tools/libclang/CXCompilationDatabase.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2014-03-20 12:48:36 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2014-03-20 12:48:36 +0000
commit2b15c2a755466bc5460fbdc42c438bcbc196583a (patch)
tree971f4834c206b0b7d2f694bec050ee6f26c767e8 /tools/libclang/CXCompilationDatabase.cpp
parentc6fe0ccf5fd46fc414b2356a20ef9fadb514ccf5 (diff)
downloadclang-2b15c2a755466bc5460fbdc42c438bcbc196583a.tar.gz
clang-2b15c2a755466bc5460fbdc42c438bcbc196583a.tar.bz2
clang-2b15c2a755466bc5460fbdc42c438bcbc196583a.tar.xz
Tooling: Move heavyweight vectors around instead of copying.
While there convert to range-based for loops. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204338 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/CXCompilationDatabase.cpp')
-rw-r--r--tools/libclang/CXCompilationDatabase.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/tools/libclang/CXCompilationDatabase.cpp b/tools/libclang/CXCompilationDatabase.cpp
index 156a3e22a6..f4728fe0a1 100644
--- a/tools/libclang/CXCompilationDatabase.cpp
+++ b/tools/libclang/CXCompilationDatabase.cpp
@@ -40,9 +40,8 @@ struct AllocatedCXCompileCommands
{
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 @@ clang_CompilationDatabase_getCompileCommands(CXCompilationDatabase CDb,
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 @@ clang_CompilationDatabase_getCompileCommands(CXCompilationDatabase CDb,
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;