Commit c85bb007 authored by Pavel Solodovnikov's avatar Pavel Solodovnikov

Reduce allocation of temporary values on heap.

- Use `std::move` while inserting temporary results into vectors.
- Change `push_back` to `emplace_back` where appropriate.
parent fa3ac83a
......@@ -467,7 +467,7 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
std::string name = cmSystemTools::GetFilenameName(this->Resources[i]);
std::string path = this->Directory + "/resources/" + name;
cmsys::SystemTools::CopyFileIfDifferent(this->Resources[i], path);
resources.push_back(name);
resources.push_back(std::move(name));
} else {
cmCPackIFWLogger(WARNING, "Can't copy resources from \""
<< this->Resources[i]
......
......@@ -132,7 +132,7 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
}
}
// add the generated package to package file names list
packageFileNames.push_back(packageFileName);
packageFileNames.push_back(std::move(packageFileName));
}
// Handle Orphan components (components not belonging to any groups)
for (auto& comp : this->Components) {
......@@ -157,7 +157,7 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
addOneComponentToArchive(archive, &(comp.second));
}
// add the generated package to package file names list
packageFileNames.push_back(packageFileName);
packageFileNames.push_back(std::move(packageFileName));
}
}
}
......@@ -178,7 +178,7 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
addOneComponentToArchive(archive, &(comp.second));
}
// add the generated package to package file names list
packageFileNames.push_back(packageFileName);
packageFileNames.push_back(std::move(packageFileName));
}
}
return 1;
......@@ -188,7 +188,7 @@ int cmCPackArchiveGenerator::PackageComponentsAllInOne()
{
// reset the package file names
packageFileNames.clear();
packageFileNames.push_back(std::string(toplevel));
packageFileNames.emplace_back(toplevel);
packageFileNames[0] += "/";
if (this->IsSet("CPACK_ARCHIVE_FILE_NAME")) {
......
......@@ -89,7 +89,7 @@ int cmCPackDebGenerator::PackageOnePack(std::string const& initialTopLevel,
packageFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
packageFileName += "/";
packageFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME");
packageFileNames.push_back(packageFileName);
packageFileNames.push_back(std::move(packageFileName));
return retval;
}
......@@ -206,7 +206,7 @@ int cmCPackDebGenerator::PackageComponentsAllInOne(
packageFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
packageFileName += "/";
packageFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME");
packageFileNames.push_back(packageFileName);
packageFileNames.push_back(std::move(packageFileName));
return retval;
}
......
......@@ -313,7 +313,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
for (std::string const& ifr : ignoreFilesRegexString) {
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Create ignore files regex for: " << ifr << std::endl);
ignoreFilesRegex.push_back(ifr.c_str());
ignoreFilesRegex.emplace_back(ifr);
}
}
const char* installDirectories =
......@@ -383,8 +383,8 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
std::string inFileRelative =
cmSystemTools::RelativePath(top.c_str(), inFile.c_str());
cmSystemTools::ReadSymlink(inFile, targetFile);
symlinkedFiles.push_back(
std::pair<std::string, std::string>(targetFile, inFileRelative));
symlinkedFiles.emplace_back(std::move(targetFile),
std::move(inFileRelative));
}
/* If it is not a symlink then do a plain copy */
else if (!(cmSystemTools::CopyFileIfDifferent(inFile.c_str(),
......
......@@ -115,7 +115,7 @@ int cmCPackNSISGenerator::PackageFiles()
dstr << " RMDir \"" << componentOutputDir << "\\" << fileN << "\""
<< std::endl;
if (!componentName.empty()) {
this->Components[componentName].Directories.push_back(fileN);
this->Components[componentName].Directories.push_back(std::move(fileN));
}
}
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: " << dstr.str()
......
......@@ -432,7 +432,7 @@ int main(int argc, char const* const* argv)
cmDocumentationEntry e;
e.Name = g.first;
e.Brief = g.second;
v.push_back(e);
v.push_back(std::move(e));
}
doc.SetSection("Generators", v);
......
......@@ -51,19 +51,13 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
args.push_back(cmSystemTools::GetCMakeCommand());
args.push_back(this->SourceDir);
if (!this->BuildGenerator.empty()) {
std::string generator = "-G";
generator += this->BuildGenerator;
args.push_back(generator);
args.push_back("-G" + this->BuildGenerator);
}
if (!this->BuildGeneratorPlatform.empty()) {
std::string platform = "-A";
platform += this->BuildGeneratorPlatform;
args.push_back(platform);
args.push_back("-A" + this->BuildGeneratorPlatform);
}
if (!this->BuildGeneratorToolset.empty()) {
std::string toolset = "-T";
toolset += this->BuildGeneratorToolset;
args.push_back(toolset);
args.push_back("-T" + this->BuildGeneratorToolset);
}
const char* config = nullptr;
......@@ -77,8 +71,7 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
#endif
if (config) {
std::string btype = "-DCMAKE_BUILD_TYPE:STRING=" + std::string(config);
args.push_back(btype);
args.push_back("-DCMAKE_BUILD_TYPE:STRING=" + std::string(config));
}
for (std::string const& opt : this->BuildOptions) {
......
......@@ -17,6 +17,7 @@
#include <set>
#include <stdlib.h>
#include <string.h>
#include <utility>
static const char* cmCTestErrorMatches[] = {
"^[Bb]us [Ee]rror",
......@@ -294,7 +295,7 @@ int cmCTestBuildHandler::ProcessHandler()
cmCTestWarningErrorFileLine[entry].RegularExpressionString)) {
r.FileIndex = cmCTestWarningErrorFileLine[entry].FileIndex;
r.LineIndex = cmCTestWarningErrorFileLine[entry].LineIndex;
this->ErrorWarningFileLineRegex.push_back(r);
this->ErrorWarningFileLineRegex.push_back(std::move(r));
} else {
cmCTestLog(
this->CTest, ERROR_MESSAGE, "Problem Compiling regular expression: "
......@@ -894,7 +895,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
errorwarning.PreContext.clear();
errorwarning.PostContext.clear();
errorwarning.Error = false;
this->ErrorsAndWarnings.push_back(errorwarning);
this->ErrorsAndWarnings.push_back(std::move(errorwarning));
this->TotalWarnings++;
}
}
......@@ -917,7 +918,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
errorwarning.PreContext.clear();
errorwarning.PostContext.clear();
errorwarning.Error = true;
this->ErrorsAndWarnings.push_back(errorwarning);
this->ErrorsAndWarnings.push_back(std::move(errorwarning));
this->TotalErrors++;
cmCTestLog(this->CTest, ERROR_MESSAGE, "There was an error: "
<< cmsysProcess_GetErrorString(cp) << std::endl);
......@@ -1009,7 +1010,7 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length,
this->PreContext.clear();
// Store report
this->ErrorsAndWarnings.push_back(errorwarning);
this->ErrorsAndWarnings.push_back(std::move(errorwarning));
this->LastErrorOrWarning = this->ErrorsAndWarnings.end() - 1;
this->PostContextCount = 0;
} else {
......
......@@ -564,7 +564,7 @@ void cmCTestLaunch::LoadScrapeRules(
std::string line;
cmsys::RegularExpression rex;
while (cmSystemTools::GetLineFromStream(fin, line)) {
if (rex.compile(line.c_str())) {
if (rex.compile(line)) {
regexps.push_back(rex);
}
}
......
......@@ -14,6 +14,7 @@
#include <iostream>
#include <sstream>
#include <string.h>
#include <utility>
struct CatToErrorType
{
......@@ -545,12 +546,12 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
<< std::endl);
return false;
}
std::string suppressions = "--suppressions=" +
this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
this->MemoryTesterOptions.push_back(suppressions);
this->MemoryTesterOptions.push_back(
"--suppressions=" +
this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile"));
}
std::string outputFile = "--log-file=" + this->MemoryTesterOutputFile;
this->MemoryTesterDynamicOptions.push_back(outputFile);
this->MemoryTesterDynamicOptions.push_back("--log-file=" +
this->MemoryTesterOutputFile);
break;
}
case cmCTestMemCheckHandler::PURIFY: {
......@@ -588,7 +589,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
"/Testing/Temporary/MemoryChecker.??.DPbd";
this->BoundsCheckerDPBDFile = dpbdFile;
this->MemoryTesterDynamicOptions.push_back("/B");
this->MemoryTesterDynamicOptions.push_back(dpbdFile);
this->MemoryTesterDynamicOptions.push_back(std::move(dpbdFile));
this->MemoryTesterDynamicOptions.push_back("/X");
this->MemoryTesterDynamicOptions.push_back(this->MemoryTesterOutputFile);
this->MemoryTesterOptions.push_back("/M");
......@@ -1098,5 +1099,5 @@ void cmCTestMemCheckHandler::TestOutputFileNames(
cmCTestLog(this->CTest, ERROR_MESSAGE, log << std::endl);
ofile.clear();
}
files.push_back(ofile);
files.push_back(std::move(ofile));
}
......@@ -570,7 +570,7 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList()
TestSet alreadySortedTests;
std::list<TestSet> priorityStack;
priorityStack.push_back(TestSet());
priorityStack.emplace_back();
TestSet& topLevel = priorityStack.back();
// In parallel test runs add previously failed tests to the front
......@@ -592,7 +592,7 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList()
// further dependencies exist.
while (!priorityStack.back().empty()) {
TestSet& previousSet = priorityStack.back();
priorityStack.push_back(TestSet());
priorityStack.emplace_back();
TestSet& currentSet = priorityStack.back();
for (auto const& i : previousSet) {
......
......@@ -515,7 +515,7 @@ private:
} else {
local_path = path;
}
this->SVN->Repositories.push_back(SVNInfo(local_path.c_str()));
this->SVN->Repositories.emplace_back(local_path.c_str());
}
};
......@@ -526,7 +526,7 @@ bool cmCTestSVN::LoadRepositories()
}
// Info for root repository
this->Repositories.push_back(SVNInfo(""));
this->Repositories.emplace_back("");
this->RootInfo = &(this->Repositories.back());
// Run "svn status" to get the list of external repositories
......
......@@ -2156,9 +2156,7 @@ bool cmCTestTestHandler::SetTestsProperties(
std::vector<std::string> lval;
cmSystemTools::ExpandListArgument(val, lval);
for (std::string const& cr : lval) {
rt.ErrorRegularExpressions.push_back(
std::pair<cmsys::RegularExpression, std::string>(
cmsys::RegularExpression(cr.c_str()), std::string(cr)));
rt.ErrorRegularExpressions.emplace_back(cr, cr);
}
}
if (key == "PROCESSORS") {
......@@ -2204,9 +2202,7 @@ bool cmCTestTestHandler::SetTestsProperties(
std::vector<std::string> lval;
cmSystemTools::ExpandListArgument(val, lval);
for (std::string const& cr : lval) {
rt.RequiredRegularExpressions.push_back(
std::pair<cmsys::RegularExpression, std::string>(
cmsys::RegularExpression(cr.c_str()), std::string(cr)));
rt.RequiredRegularExpressions.emplace_back(cr, cr);
}
}
if (key == "WORKING_DIRECTORY") {
......@@ -2225,9 +2221,7 @@ bool cmCTestTestHandler::SetTestsProperties(
std::vector<std::string> lval;
cmSystemTools::ExpandListArgument(propArgs[1], lval);
for (std::string const& cr : lval) {
rt.TimeoutRegularExpressions.push_back(
std::pair<cmsys::RegularExpression, std::string>(
cmsys::RegularExpression(cr.c_str()), std::string(cr)));
rt.TimeoutRegularExpressions.emplace_back(cr, cr);
}
}
}
......
......@@ -3,6 +3,7 @@
#include "cmAddCustomCommandCommand.h"
#include <sstream>
#include <utility>
#include "cmCustomCommand.h"
#include "cmCustomCommandLines.h"
......@@ -184,9 +185,7 @@ bool cmAddCustomCommandCommand::InitialPass(
depends.push_back(dep);
// Add the implicit dependency language and file.
cmCustomCommand::ImplicitDependsPair entry(implicit_depends_lang,
dep);
implicit_depends.push_back(entry);
implicit_depends.emplace_back(implicit_depends_lang, dep);
// Switch back to looking for a language.
doing = doing_implicit_depends_lang;
......@@ -200,7 +199,7 @@ bool cmAddCustomCommandCommand::InitialPass(
case doing_depends: {
std::string dep = copy;
cmSystemTools::ConvertToUnixSlashes(dep);
depends.push_back(dep);
depends.push_back(std::move(dep));
} break;
case doing_outputs:
outputs.push_back(filename);
......
......@@ -3,6 +3,7 @@
#include "cmAddCustomTargetCommand.h"
#include <sstream>
#include <utility>
#include "cmCustomCommandLines.h"
#include "cmGeneratorExpression.h"
......@@ -127,7 +128,7 @@ bool cmAddCustomTargetCommand::InitialPass(
case doing_depends: {
std::string dep = copy;
cmSystemTools::ConvertToUnixSlashes(dep);
depends.push_back(dep);
depends.push_back(std::move(dep));
} break;
case doing_comment:
comment_buffer = copy;
......
......@@ -63,7 +63,7 @@ bool cmAuxSourceDirectoryCommand::InitialPass(
// depends can be done
cmSourceFile* sf = this->Makefile->GetOrCreateSource(fullname);
sf->SetProperty("ABSTRACT", "0");
files.push_back(fullname);
files.push_back(std::move(fullname));
}
}
}
......
......@@ -159,7 +159,7 @@ std::vector<std::string> cmCommonTargetGenerator::GetLinkedTargetDirectories()
std::string di = lg->GetCurrentBinaryDirectory();
di += "/";
di += lg->GetTargetDirectory(linkee);
dirs.push_back(di);
dirs.push_back(std::move(di));
}
}
}
......
......@@ -88,7 +88,7 @@ void cmComputeComponentGraph::TarjanVisit(int i)
if (this->TarjanEntries[i].Root == i) {
// Yes. Create it.
int c = static_cast<int>(this->Components.size());
this->Components.push_back(NodeList());
this->Components.emplace_back();
NodeList& component = this->Components[c];
// Populate the component list.
......@@ -125,8 +125,8 @@ void cmComputeComponentGraph::TransferEdges()
if (i_component != j_component) {
// We do not attempt to combine duplicate edges, but instead
// store the inter-component edges with suitable multiplicity.
this->ComponentGraph[i_component].push_back(
cmGraphEdge(j_component, ni.IsStrong()));
this->ComponentGraph[i_component].emplace_back(j_component,
ni.IsStrong());
}
}
}
......
......@@ -285,9 +285,9 @@ std::map<std::string, int>::iterator cmComputeLinkDepends::AllocateLinkEntry(
item, static_cast<int>(this->EntryList.size()));
std::map<std::string, int>::iterator lei =
this->LinkEntryIndex.insert(index_entry).first;
this->EntryList.push_back(LinkEntry());
this->EntryList.emplace_back();
this->InferredDependSets.push_back(nullptr);
this->EntryConstraintGraph.push_back(EdgeList());
this->EntryConstraintGraph.emplace_back();
return lei;
}
......@@ -472,8 +472,7 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
// If the library is meant for this link type then use it.
if (llt == GENERAL_LibraryType || llt == this->LinkType) {
cmLinkItem item(d, this->FindTargetToLink(depender_index, d));
actual_libs.push_back(item);
actual_libs.emplace_back(d, this->FindTargetToLink(depender_index, d));
} else if (this->OldLinkDirMode) {
cmLinkItem item(d, this->FindTargetToLink(depender_index, d));
this->CheckWrongConfigItem(item);
......
......@@ -498,8 +498,8 @@ bool cmComputeLinkInformation::Compute()
cmStateEnums::ArtifactType artifact = implib
? cmStateEnums::ImportLibraryArtifact
: cmStateEnums::RuntimeBinaryArtifact;
std::string lib = tgt->GetFullPath(this->Config, artifact, true);
this->OldLinkDirItems.push_back(lib);
this->OldLinkDirItems.push_back(
tgt->GetFullPath(this->Config, artifact, true));
}
}
......@@ -598,13 +598,13 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
std::string exe = tgt->GetFullPath(config, artifact, true);
linkItem += exe;
this->Items.push_back(Item(linkItem, true, tgt));
this->Depends.push_back(exe);
this->Items.emplace_back(linkItem, true, tgt);
this->Depends.push_back(std::move(exe));
} else if (tgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
// Add the interface library as an item so it can be considered as part
// of COMPATIBLE_INTERFACE_ enforcement. The generators will ignore
// this for the actual link line.
this->Items.push_back(Item(std::string(), false, tgt));
this->Items.emplace_back(std::string(), false, tgt);
// Also add the item the interface specifies to be used in its place.
std::string const& libName = tgt->GetImportedLibName(config);
......@@ -950,10 +950,10 @@ void cmComputeLinkInformation::SetCurrentLinkType(LinkType lt)
if (this->LinkTypeEnabled) {
switch (this->CurrentLinkType) {
case LinkStatic:
this->Items.push_back(Item(this->StaticLinkTypeFlag, false));
this->Items.emplace_back(this->StaticLinkTypeFlag, false);
break;
case LinkShared:
this->Items.push_back(Item(this->SharedLinkTypeFlag, false));
this->Items.emplace_back(this->SharedLinkTypeFlag, false);
break;
default:
break;
......@@ -989,7 +989,7 @@ void cmComputeLinkInformation::AddTargetItem(std::string const& item,
// If this platform wants a flag before the full path, add it.
if (!this->LibLinkFileFlag.empty()) {
this->Items.push_back(Item(this->LibLinkFileFlag, false));
this->Items.emplace_back(this->LibLinkFileFlag, false);
}
// For compatibility with CMake 2.4 include the item's directory in
......@@ -1001,7 +1001,7 @@ void cmComputeLinkInformation::AddTargetItem(std::string const& item,
}
// Now add the full path to the library.
this->Items.push_back(Item(item, true, target));
this->Items.emplace_back(item, true, target);
}
void cmComputeLinkInformation::AddFullItem(std::string const& item)
......@@ -1056,11 +1056,11 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item)
// If this platform wants a flag before the full path, add it.
if (!this->LibLinkFileFlag.empty()) {
this->Items.push_back(Item(this->LibLinkFileFlag, false));
this->Items.emplace_back(this->LibLinkFileFlag, false);
}
// Now add the full path to the library.
this->Items.push_back(Item(item, true));
this->Items.emplace_back(item, true);
}
bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item)
......@@ -1147,7 +1147,7 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
this->SetCurrentLinkType(this->StartLinkType);
// Use the item verbatim.
this->Items.push_back(Item(item, false));
this->Items.emplace_back(item, false);
return;
}
......@@ -1219,7 +1219,7 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
std::string out = this->LibLinkFlag;
out += lib;
out += this->LibLinkSuffix;
this->Items.push_back(Item(out, false));
this->Items.emplace_back(out, false);
// Here we could try to find the library the linker will find and
// add a runtime information entry for it. It would probably not be
......@@ -1254,10 +1254,10 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item)
this->AddLibraryRuntimeInfo(full_fw);
// Add the item using the -framework option.
this->Items.push_back(Item("-framework", false));
this->Items.emplace_back("-framework", false);
cmOutputConverter converter(this->Makefile->GetStateSnapshot());
fw = converter.EscapeForShell(fw);
this->Items.push_back(Item(fw, false));
this->Items.emplace_back(fw, false);
}
void cmComputeLinkInformation::AddDirectoryItem(std::string const& item)
......@@ -1742,7 +1742,7 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
cmSystemTools::ConvertToUnixSlashes(d);
}
if (emitted.insert(d).second) {
runtimeDirs.push_back(d);
runtimeDirs.push_back(std::move(d));
}
} else if (use_link_rpath) {
// Do not add any path inside the source or build tree.
......@@ -1764,7 +1764,7 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
cmSystemTools::ConvertToUnixSlashes(d);
}
if (emitted.insert(d).second) {
runtimeDirs.push_back(d);
runtimeDirs.push_back(std::move(d));
}
}
}
......
......@@ -200,7 +200,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
std::vector<std::string> configs;
depender->Makefile->GetConfigurations(configs);
if (configs.empty()) {
configs.push_back("");
configs.emplace_back();
}
for (std::string const& it : configs) {
std::vector<cmSourceFile const*> objectFiles;
......@@ -369,8 +369,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
int dependee_index = tii->second;
// Add this entry to the dependency graph.
this->InitialGraph[depender_index].push_back(
cmGraphEdge(dependee_index, !linking));
this->InitialGraph[depender_index].emplace_back(dependee_index, !linking);
}
}
......@@ -504,7 +503,7 @@ bool cmComputeTargetDepends::IntraComponent(std::vector<int> const& cmap,
for (cmGraphEdge const& edge : el) {
int j = edge;
if (cmap[j] == c && edge.IsStrong()) {
this->FinalGraph[i].push_back(cmGraphEdge(j, true));
this->FinalGraph[i].emplace_back(j, true);
if (!this->IntraComponent(cmap, c, j, head, emitted, visited)) {
return false;
}
......@@ -513,7 +512,7 @@ bool cmComputeTargetDepends::IntraComponent(std::vector<int> const& cmap,
// Prepend to a linear linked-list of intra-component edges.
if (*head >= 0) {
this->FinalGraph[i].push_back(cmGraphEdge(*head, false));
this->FinalGraph[i].emplace_back(*head, false);
} else {
this->ComponentTail[c] = i;
}
......@@ -563,8 +562,8 @@ bool cmComputeTargetDepends::ComputeFinalDepends(
for (cmGraphEdge const& ni : nl) {
int dependee_component = ni;
int dependee_component_head = this->ComponentHead[dependee_component];
this->FinalGraph[depender_component_tail].push_back(
cmGraphEdge(dependee_component_head, ni.IsStrong()));
this->FinalGraph[depender_component_tail].emplace_back(
dependee_component_head, ni.IsStrong());
}
}
return true;
......
......@@ -631,13 +631,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
kCMAKE_TRY_COMPILE_OSX_ARCHITECTURES)) {
vars.erase(kCMAKE_OSX_ARCHITECTURES);
std::string flag = "-DCMAKE_OSX_ARCHITECTURES=" + std::string(tcArchs);
cmakeFlags.push_back(flag);
cmakeFlags.push_back(std::move(flag));
}
for (std::string const& var : vars) {
if (const char* val = this->Makefile->GetDefinition(var)) {
std::string flag = "-D" + var + "=" + val;
cmakeFlags.push_back(flag);
cmakeFlags.push_back(std::move(flag));
}
}
}
......@@ -938,7 +938,7 @@ void cmCoreTryCompile::FindOutputFile(const std::string& targetName,
// a list of directories where to search for the compilation result
// at first directly in the binary dir
std::vector<std::string> searchDirs;
searchDirs.push_back("");
searchDirs.emplace_back();
const char* config =
this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
......@@ -946,12 +946,12 @@ void cmCoreTryCompile::FindOutputFile(const std::string& targetName,
if (config && config[0]) {
std::string tmp = "/";
tmp += config;
searchDirs.push_back(tmp);
searchDirs.push_back(std::move(tmp));
}
searchDirs.push_back("/Debug");
#if defined(__APPLE__)
std::string app = "/Debug/" + targetName + ".app";
searchDirs.push_back(app);
searchDirs.push_back(std::move(app));
#endif
searchDirs.push_back("/Development");
......
......@@ -14,6 +14,7 @@
#include <memory> // IWYU pragma: keep
#include <stddef.h>
#include <utility>
cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
const std::string& config,
......@@ -37,10 +38,10 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
cmSystemTools::ExpandListArgument(parsed_arg, ExpandedArg);
argv.insert(argv.end(), ExpandedArg.begin(), ExpandedArg.end());
} else {
argv.push_back(parsed_arg);
argv.push_back(std::move(parsed_arg));
}
}
this->CommandLines.push_back(argv);
this->CommandLines.push_back(std::move(argv));
}
std::vector<std::string> depends = this->CC.GetDepends();
......
......@@ -303,7 +303,7 @@ void cmDependsC::ReadCacheFile()
if (line != "-") {
entry.QuotedLocation = line;
}
cacheEntry->UnscannedEntries.push_back(entry);
cacheEntry->UnscannedEntries.push_back(std::move(entry));
}
}
}
......
......@@ -10,6 +10,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <utility>
int cmDependsJava_yyparse(yyscan_t yyscanner);
......@@ -22,7 +23,7 @@ cmDependsJavaParserHelper::cmDependsJavaParserHelper()
CurrentClass tl;
tl.Name = "*";
this->ClassStack.push_back(tl);
this->ClassStack.push_back(std::move(tl));
}
cmDependsJavaParserHelper::~cmDependsJavaParserHelper()
......@@ -175,7 +176,7 @@ void cmDependsJavaParserHelper::StartClass(const char* cls)
{
CurrentClass cl;
cl.Name = cls;
this->ClassStack.push_back(cl);
this->ClassStack.push_back(std::move(cl));
this->CurrentDepth++;
}
......
......@@ -213,7 +213,7 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
if (argc == 1) {
RequestedHelpItem help;
help.HelpType = cmDocumentation::Usage;
this->RequestedHelpItems.push_back(help);
this->RequestedHelpItems.push_back(std::move(help));
return true;
}
......@@ -352,7 +352,7 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
if (help.HelpType != None) {