cmGlobalNinjaGenerator: Optimize handling of known build outputs

Teach WriteUnknownExplicitDependencies to take ownership of the set of
WriteBuild outputs immediately since no other methods need the data.
This avoids re-inserting the whole set into another already populated
set.
This commit is contained in:
Brad King 2015-03-18 16:24:11 -04:00
parent ad094f435e
commit ed8e30b00d

View File

@ -955,6 +955,13 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os)
void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
{
// We need to collect the set of known build outputs.
// Start with those generated by WriteBuild calls.
// No other method needs this so we can take ownership
// of the set locally and throw it out when we are done.
std::set<std::string> knownDependencies;
knownDependencies.swap(this->CombinedBuildOutputs);
//now write out the unknown explicit dependencies.
//union the configured files, evaluations files and the CombinedBuildOutputs,
@ -971,7 +978,6 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
cmLocalNinjaGenerator *ng =
static_cast<cmLocalNinjaGenerator *>(this->LocalGenerators[0]);
std::set<std::string> knownDependencies;
for (std::vector<cmLocalGenerator *>::const_iterator i =
this->LocalGenerators.begin(); i != this->LocalGenerators.end(); ++i)
{
@ -1026,15 +1032,6 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
knownDependencies.insert( ng->ConvertToNinjaPath(i->first) );
}
//insert outputs from all WirteBuild commands
//these paths have already be encoded when added to CombinedBuildOutputs
knownDependencies.insert(this->CombinedBuildOutputs.begin(),
this->CombinedBuildOutputs.end());
//after we have combined the data into knownDependencies we have no need
//to keep this data around
this->CombinedBuildOutputs.clear();
//now we difference with CombinedCustomCommandExplicitDependencies to find
//the list of items we know nothing about.
//We have encoded all the paths in CombinedCustomCommandExplicitDependencies