mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-05 22:28:35 -06:00
Source: Reduce vector entry allocations and copies
Prefer `emplace_back` over `push_back`.
This commit is contained in:
@@ -579,8 +579,9 @@ bool cmCPackInnoSetupGenerator::ProcessFiles()
|
|||||||
|
|
||||||
bool cmCPackInnoSetupGenerator::ProcessComponents()
|
bool cmCPackInnoSetupGenerator::ProcessComponents()
|
||||||
{
|
{
|
||||||
codeIncludes.push_back("{ The following lines are required by CPack because "
|
codeIncludes.emplace_back(
|
||||||
"this script uses components }");
|
"{ The following lines are required by CPack because "
|
||||||
|
"this script uses components }");
|
||||||
|
|
||||||
// Installation types
|
// Installation types
|
||||||
std::vector<cmCPackInstallationType*> types(InstallationTypes.size());
|
std::vector<cmCPackInstallationType*> types(InstallationTypes.size());
|
||||||
@@ -607,7 +608,7 @@ bool cmCPackInnoSetupGenerator::ProcessComponents()
|
|||||||
"\"{code:CPackGetCustomInstallationMessage}\"";
|
"\"{code:CPackGetCustomInstallationMessage}\"";
|
||||||
customTypeParams["Flags"] = "iscustom";
|
customTypeParams["Flags"] = "iscustom";
|
||||||
|
|
||||||
allTypes.push_back("custom");
|
allTypes.emplace_back("custom");
|
||||||
typeInstructions.push_back(ISKeyValueLine(customTypeParams));
|
typeInstructions.push_back(ISKeyValueLine(customTypeParams));
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
|
|||||||
@@ -374,7 +374,7 @@ bool cmCTestBZR::UpdateImpl()
|
|||||||
// Use "bzr pull" to update the working tree.
|
// Use "bzr pull" to update the working tree.
|
||||||
std::vector<std::string> bzr_update;
|
std::vector<std::string> bzr_update;
|
||||||
bzr_update.push_back(this->CommandLineTool);
|
bzr_update.push_back(this->CommandLineTool);
|
||||||
bzr_update.push_back("pull");
|
bzr_update.emplace_back("pull");
|
||||||
|
|
||||||
cm::append(bzr_update, args);
|
cm::append(bzr_update, args);
|
||||||
|
|
||||||
|
|||||||
@@ -92,8 +92,8 @@ bool cmCTestCVS::UpdateImpl()
|
|||||||
// Run "cvs update" to update the work tree.
|
// Run "cvs update" to update the work tree.
|
||||||
std::vector<std::string> cvs_update;
|
std::vector<std::string> cvs_update;
|
||||||
cvs_update.push_back(this->CommandLineTool);
|
cvs_update.push_back(this->CommandLineTool);
|
||||||
cvs_update.push_back("-z3");
|
cvs_update.emplace_back("-z3");
|
||||||
cvs_update.push_back("update");
|
cvs_update.emplace_back("update");
|
||||||
cm::append(cvs_update, args);
|
cm::append(cvs_update, args);
|
||||||
|
|
||||||
UpdateParser out(this, "up-out> ");
|
UpdateParser out(this, "up-out> ");
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ bool cmCTestGIT::UpdateByFetchAndReset()
|
|||||||
// Use "git fetch" to get remote commits.
|
// Use "git fetch" to get remote commits.
|
||||||
std::vector<std::string> git_fetch;
|
std::vector<std::string> git_fetch;
|
||||||
git_fetch.push_back(git);
|
git_fetch.push_back(git);
|
||||||
git_fetch.push_back("fetch");
|
git_fetch.emplace_back("fetch");
|
||||||
|
|
||||||
// Add user-specified update options.
|
// Add user-specified update options.
|
||||||
std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
|
std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
|
||||||
|
|||||||
@@ -137,9 +137,9 @@ bool cmCTestHG::UpdateImpl()
|
|||||||
// TODO: if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
|
// TODO: if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
|
||||||
|
|
||||||
std::vector<std::string> hg_update;
|
std::vector<std::string> hg_update;
|
||||||
hg_update.push_back(this->CommandLineTool.c_str());
|
hg_update.emplace_back(this->CommandLineTool);
|
||||||
hg_update.push_back("update");
|
hg_update.emplace_back("update");
|
||||||
hg_update.push_back("-v");
|
hg_update.emplace_back("-v");
|
||||||
|
|
||||||
// Add user-specified update options.
|
// Add user-specified update options.
|
||||||
std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
|
std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
|
||||||
|
|||||||
@@ -151,9 +151,9 @@ cmCTestP4::User cmCTestP4::GetUserData(const std::string& username)
|
|||||||
if (it == this->Users.end()) {
|
if (it == this->Users.end()) {
|
||||||
std::vector<std::string> p4_users;
|
std::vector<std::string> p4_users;
|
||||||
this->SetP4Options(p4_users);
|
this->SetP4Options(p4_users);
|
||||||
p4_users.push_back("users");
|
p4_users.emplace_back("users");
|
||||||
p4_users.push_back("-m");
|
p4_users.emplace_back("-m");
|
||||||
p4_users.push_back("1");
|
p4_users.emplace_back("1");
|
||||||
p4_users.push_back(username);
|
p4_users.push_back(username);
|
||||||
|
|
||||||
UserParser out(this, "users-out> ");
|
UserParser out(this, "users-out> ");
|
||||||
@@ -335,10 +335,10 @@ std::string cmCTestP4::GetWorkingRevision()
|
|||||||
std::vector<std::string> p4_identify;
|
std::vector<std::string> p4_identify;
|
||||||
this->SetP4Options(p4_identify);
|
this->SetP4Options(p4_identify);
|
||||||
|
|
||||||
p4_identify.push_back("changes");
|
p4_identify.emplace_back("changes");
|
||||||
p4_identify.push_back("-m");
|
p4_identify.emplace_back("-m");
|
||||||
p4_identify.push_back("1");
|
p4_identify.emplace_back("1");
|
||||||
p4_identify.push_back("-t");
|
p4_identify.emplace_back("-t");
|
||||||
|
|
||||||
std::string source = this->SourceDirectory + "/...#have";
|
std::string source = this->SourceDirectory + "/...#have";
|
||||||
p4_identify.push_back(source);
|
p4_identify.push_back(source);
|
||||||
@@ -403,7 +403,7 @@ bool cmCTestP4::LoadRevisions()
|
|||||||
.append(",")
|
.append(",")
|
||||||
.append(this->NewRevision);
|
.append(this->NewRevision);
|
||||||
|
|
||||||
p4_changes.push_back("changes");
|
p4_changes.emplace_back("changes");
|
||||||
p4_changes.push_back(range);
|
p4_changes.push_back(range);
|
||||||
|
|
||||||
ChangesParser out(this, "p4_changes-out> ");
|
ChangesParser out(this, "p4_changes-out> ");
|
||||||
@@ -420,8 +420,8 @@ bool cmCTestP4::LoadRevisions()
|
|||||||
std::vector<std::string> p4_describe;
|
std::vector<std::string> p4_describe;
|
||||||
for (std::string const& i : cmReverseRange(this->ChangeLists)) {
|
for (std::string const& i : cmReverseRange(this->ChangeLists)) {
|
||||||
this->SetP4Options(p4_describe);
|
this->SetP4Options(p4_describe);
|
||||||
p4_describe.push_back("describe");
|
p4_describe.emplace_back("describe");
|
||||||
p4_describe.push_back("-s");
|
p4_describe.emplace_back("-s");
|
||||||
p4_describe.push_back(i);
|
p4_describe.push_back(i);
|
||||||
|
|
||||||
DescribeParser outDescribe(this, "p4_describe-out> ");
|
DescribeParser outDescribe(this, "p4_describe-out> ");
|
||||||
@@ -436,10 +436,10 @@ bool cmCTestP4::LoadModifications()
|
|||||||
std::vector<std::string> p4_diff;
|
std::vector<std::string> p4_diff;
|
||||||
this->SetP4Options(p4_diff);
|
this->SetP4Options(p4_diff);
|
||||||
|
|
||||||
p4_diff.push_back("diff");
|
p4_diff.emplace_back("diff");
|
||||||
|
|
||||||
// Ideally we would use -Od but not all clients support it
|
// Ideally we would use -Od but not all clients support it
|
||||||
p4_diff.push_back("-dn");
|
p4_diff.emplace_back("-dn");
|
||||||
std::string source = this->SourceDirectory + "/...";
|
std::string source = this->SourceDirectory + "/...";
|
||||||
p4_diff.push_back(source);
|
p4_diff.push_back(source);
|
||||||
|
|
||||||
@@ -480,7 +480,7 @@ bool cmCTestP4::UpdateImpl()
|
|||||||
std::vector<std::string> p4_sync;
|
std::vector<std::string> p4_sync;
|
||||||
this->SetP4Options(p4_sync);
|
this->SetP4Options(p4_sync);
|
||||||
|
|
||||||
p4_sync.push_back("sync");
|
p4_sync.emplace_back("sync");
|
||||||
|
|
||||||
// Get user-specified update options.
|
// Get user-specified update options.
|
||||||
std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
|
std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ cmCTestSVN::~cmCTestSVN() = default;
|
|||||||
void cmCTestSVN::CleanupImpl()
|
void cmCTestSVN::CleanupImpl()
|
||||||
{
|
{
|
||||||
std::vector<std::string> svn_cleanup;
|
std::vector<std::string> svn_cleanup;
|
||||||
svn_cleanup.push_back("cleanup");
|
svn_cleanup.emplace_back("cleanup");
|
||||||
OutputLogger out(this->Log, "cleanup-out> ");
|
OutputLogger out(this->Log, "cleanup-out> ");
|
||||||
OutputLogger err(this->Log, "cleanup-err> ");
|
OutputLogger err(this->Log, "cleanup-err> ");
|
||||||
this->RunSVNCommand(svn_cleanup, &out, &err);
|
this->RunSVNCommand(svn_cleanup, &out, &err);
|
||||||
@@ -89,7 +89,7 @@ std::string cmCTestSVN::LoadInfo(SVNInfo& svninfo)
|
|||||||
{
|
{
|
||||||
// Run "svn info" to get the repository info from the work tree.
|
// Run "svn info" to get the repository info from the work tree.
|
||||||
std::vector<std::string> svn_info;
|
std::vector<std::string> svn_info;
|
||||||
svn_info.push_back("info");
|
svn_info.emplace_back("info");
|
||||||
svn_info.push_back(svninfo.LocalPath);
|
svn_info.push_back(svninfo.LocalPath);
|
||||||
std::string rev;
|
std::string rev;
|
||||||
InfoParser out(this, "info-out> ", rev, svninfo);
|
InfoParser out(this, "info-out> ", rev, svninfo);
|
||||||
@@ -252,7 +252,7 @@ bool cmCTestSVN::UpdateImpl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> svn_update;
|
std::vector<std::string> svn_update;
|
||||||
svn_update.push_back("update");
|
svn_update.emplace_back("update");
|
||||||
cm::append(svn_update, args);
|
cm::append(svn_update, args);
|
||||||
|
|
||||||
UpdateParser out(this, "up-out> ");
|
UpdateParser out(this, "up-out> ");
|
||||||
@@ -270,7 +270,7 @@ bool cmCTestSVN::RunSVNCommand(std::vector<std::string> const& parameters,
|
|||||||
std::vector<std::string> args;
|
std::vector<std::string> args;
|
||||||
args.push_back(this->CommandLineTool);
|
args.push_back(this->CommandLineTool);
|
||||||
cm::append(args, parameters);
|
cm::append(args, parameters);
|
||||||
args.push_back("--non-interactive");
|
args.emplace_back("--non-interactive");
|
||||||
|
|
||||||
std::string userOptions = this->CTest->GetCTestConfiguration("SVNOptions");
|
std::string userOptions = this->CTest->GetCTestConfiguration("SVNOptions");
|
||||||
|
|
||||||
@@ -388,11 +388,11 @@ bool cmCTestSVN::LoadRevisions(SVNInfo& svninfo)
|
|||||||
|
|
||||||
// Run "svn log" to get all global revisions of interest.
|
// Run "svn log" to get all global revisions of interest.
|
||||||
std::vector<std::string> svn_log;
|
std::vector<std::string> svn_log;
|
||||||
svn_log.push_back("log");
|
svn_log.emplace_back("log");
|
||||||
svn_log.push_back("--xml");
|
svn_log.emplace_back("--xml");
|
||||||
svn_log.push_back("-v");
|
svn_log.emplace_back("-v");
|
||||||
svn_log.push_back(revs.c_str());
|
svn_log.emplace_back(revs);
|
||||||
svn_log.push_back(svninfo.LocalPath.c_str());
|
svn_log.emplace_back(svninfo.LocalPath);
|
||||||
LogParser out(this, "log-out> ", svninfo);
|
LogParser out(this, "log-out> ", svninfo);
|
||||||
OutputLogger err(this->Log, "log-err> ");
|
OutputLogger err(this->Log, "log-err> ");
|
||||||
return this->RunSVNCommand(svn_log, &out, &err);
|
return this->RunSVNCommand(svn_log, &out, &err);
|
||||||
@@ -467,7 +467,7 @@ bool cmCTestSVN::LoadModifications()
|
|||||||
{
|
{
|
||||||
// Run "svn status" which reports local modifications.
|
// Run "svn status" which reports local modifications.
|
||||||
std::vector<std::string> svn_status;
|
std::vector<std::string> svn_status;
|
||||||
svn_status.push_back("status");
|
svn_status.emplace_back("status");
|
||||||
StatusParser out(this, "status-out> ");
|
StatusParser out(this, "status-out> ");
|
||||||
OutputLogger err(this->Log, "status-err> ");
|
OutputLogger err(this->Log, "status-err> ");
|
||||||
this->RunSVNCommand(svn_status, &out, &err);
|
this->RunSVNCommand(svn_status, &out, &err);
|
||||||
@@ -529,7 +529,7 @@ bool cmCTestSVN::LoadRepositories()
|
|||||||
|
|
||||||
// Run "svn status" to get the list of external repositories
|
// Run "svn status" to get the list of external repositories
|
||||||
std::vector<std::string> svn_status;
|
std::vector<std::string> svn_status;
|
||||||
svn_status.push_back("status");
|
svn_status.emplace_back("status");
|
||||||
ExternalParser out(this, "external-out> ");
|
ExternalParser out(this, "external-out> ");
|
||||||
OutputLogger err(this->Log, "external-err> ");
|
OutputLogger err(this->Log, "external-err> ");
|
||||||
return this->RunSVNCommand(svn_status, &out, &err);
|
return this->RunSVNCommand(svn_status, &out, &err);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ cmJSONState::cmJSONState(const std::string& filename, Json::Value* root)
|
|||||||
|
|
||||||
void cmJSONState::AddError(std::string const& errMsg)
|
void cmJSONState::AddError(std::string const& errMsg)
|
||||||
{
|
{
|
||||||
this->errors.push_back(Error(errMsg));
|
this->errors.emplace_back(errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmJSONState::AddErrorAtValue(std::string const& errMsg,
|
void cmJSONState::AddErrorAtValue(std::string const& errMsg,
|
||||||
@@ -65,7 +65,7 @@ void cmJSONState::AddErrorAtOffset(std::string const& errMsg,
|
|||||||
this->AddError(errMsg);
|
this->AddError(errMsg);
|
||||||
} else {
|
} else {
|
||||||
Location loc = LocateInDocument(offset);
|
Location loc = LocateInDocument(offset);
|
||||||
this->errors.push_back(Error(loc, errMsg));
|
this->errors.emplace_back(loc, errMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ const Json::Value* cmJSONState::value_after(std::string const& k)
|
|||||||
|
|
||||||
void cmJSONState::push_stack(std::string const& k, const Json::Value* value)
|
void cmJSONState::push_stack(std::string const& k, const Json::Value* value)
|
||||||
{
|
{
|
||||||
this->parseStack.push_back(JsonPair(k, value));
|
this->parseStack.emplace_back(k, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmJSONState::pop_stack()
|
void cmJSONState::pop_stack()
|
||||||
|
|||||||
Reference in New Issue
Block a user