mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 02:08:27 +08:00
cmGlobalNinjaGenerator: Reduce string copies in WriteCustomCommandBuild
Re-order arguments to group those with similar roles. Use move semantics to avoid copying vectors of strings.
This commit is contained in:
@@ -311,11 +311,11 @@ void cmGlobalNinjaGenerator::AddCustomCommandRule()
|
||||
}
|
||||
|
||||
void cmGlobalNinjaGenerator::WriteCustomCommandBuild(
|
||||
const std::string& command, const std::string& description,
|
||||
const std::string& comment, const std::string& depfile,
|
||||
const std::string& job_pool, bool uses_terminal, bool restat,
|
||||
const cmNinjaDeps& outputs, const std::string& config,
|
||||
const cmNinjaDeps& explicitDeps, const cmNinjaDeps& orderOnlyDeps)
|
||||
std::string const& command, std::string const& description,
|
||||
std::string const& comment, std::string const& depfile,
|
||||
std::string const& job_pool, bool uses_terminal, bool restat,
|
||||
std::string const& config, cmNinjaDeps outputs, cmNinjaDeps explicitDeps,
|
||||
cmNinjaDeps orderOnlyDeps)
|
||||
{
|
||||
this->AddCustomCommandRule();
|
||||
|
||||
@@ -330,9 +330,9 @@ void cmGlobalNinjaGenerator::WriteCustomCommandBuild(
|
||||
{
|
||||
cmNinjaBuild build("CUSTOM_COMMAND");
|
||||
build.Comment = comment;
|
||||
build.Outputs = outputs;
|
||||
build.ExplicitDeps = explicitDeps;
|
||||
build.OrderOnlyDeps = orderOnlyDeps;
|
||||
build.Outputs = std::move(outputs);
|
||||
build.ExplicitDeps = std::move(explicitDeps);
|
||||
build.OrderOnlyDeps = std::move(orderOnlyDeps);
|
||||
|
||||
cmNinjaVars& vars = build.Variables;
|
||||
{
|
||||
@@ -1209,8 +1209,8 @@ void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies()
|
||||
"Assume dependencies for generated source file.",
|
||||
/*depfile*/ "", /*job_pool*/ "",
|
||||
/*uses_terminal*/ false,
|
||||
/*restat*/ true, cmNinjaDeps(1, asd.first), "", cmNinjaDeps(),
|
||||
orderOnlyDeps);
|
||||
/*restat*/ true, std::string(), cmNinjaDeps(1, asd.first), cmNinjaDeps(),
|
||||
std::move(orderOnlyDeps));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -110,13 +110,15 @@ public:
|
||||
void WriteBuild(std::ostream& os, cmNinjaBuild const& build,
|
||||
int cmdLineLimit = 0, bool* usedResponseFile = nullptr);
|
||||
|
||||
void WriteCustomCommandBuild(
|
||||
const std::string& command, const std::string& description,
|
||||
const std::string& comment, const std::string& depfile,
|
||||
const std::string& pool, bool uses_terminal, bool restat,
|
||||
const cmNinjaDeps& outputs, const std::string& config,
|
||||
const cmNinjaDeps& explicitDeps = cmNinjaDeps(),
|
||||
const cmNinjaDeps& orderOnlyDeps = cmNinjaDeps());
|
||||
void WriteCustomCommandBuild(std::string const& command,
|
||||
std::string const& description,
|
||||
std::string const& comment,
|
||||
std::string const& depfile,
|
||||
std::string const& pool, bool uses_terminal,
|
||||
bool restat, std::string const& config,
|
||||
cmNinjaDeps outputs,
|
||||
cmNinjaDeps explicitDeps = cmNinjaDeps(),
|
||||
cmNinjaDeps orderOnlyDeps = cmNinjaDeps());
|
||||
|
||||
void WriteMacOSXContentBuild(std::string input, std::string output,
|
||||
const std::string& config);
|
||||
|
@@ -709,8 +709,9 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
|
||||
customStep),
|
||||
this->ConstructComment(ccg), comment, depfile, cc->GetJobPool(),
|
||||
cc->GetUsesTerminal(),
|
||||
/*restat*/ !symbolic || !byproducts.empty(), ninjaOutputs, fileConfig,
|
||||
ninjaDeps, orderOnlyDeps);
|
||||
/*restat*/ !symbolic || !byproducts.empty(), fileConfig,
|
||||
std::move(ninjaOutputs), std::move(ninjaDeps),
|
||||
std::move(orderOnlyDeps));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -180,7 +180,7 @@ void cmNinjaUtilityTargetGenerator::WriteUtilBuildStatements(
|
||||
gg->WriteCustomCommandBuild(
|
||||
command, desc, "Utility command for " + this->GetTargetName(),
|
||||
/*depfile*/ "", /*job_pool*/ "", uses_terminal,
|
||||
/*restat*/ true, util_outputs, ccConfig, deps);
|
||||
/*restat*/ true, ccConfig, std::move(util_outputs), std::move(deps));
|
||||
}
|
||||
|
||||
phonyBuild.ExplicitDeps.push_back(utilCommandName);
|
||||
|
Reference in New Issue
Block a user