ninja: Don't use a stringstream to build an argument list

Streams are expensive to construct (looks like some locale-related
stuff), so use strings instead.
This commit is contained in:
Ben Boeckel 2014-02-08 00:30:18 -05:00
parent 3c64089117
commit 01b79c6385
1 changed files with 14 additions and 14 deletions

View File

@ -141,7 +141,7 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
cmGlobalNinjaGenerator::WriteComment(os, comment); cmGlobalNinjaGenerator::WriteComment(os, comment);
cmOStringStream arguments; std::string arguments;
// TODO: Better formatting for when there are multiple input/output files. // TODO: Better formatting for when there are multiple input/output files.
@ -150,7 +150,7 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
i != explicitDeps.end(); i != explicitDeps.end();
++i) ++i)
{ {
arguments << " " << EncodeIdent(EncodePath(*i), os); arguments += " " + EncodeIdent(EncodePath(*i), os);
//we need to track every dependency that comes in, since we are trying //we need to track every dependency that comes in, since we are trying
//to find dependencies that are side effects of build commands //to find dependencies that are side effects of build commands
@ -161,39 +161,39 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
// Write implicit dependencies. // Write implicit dependencies.
if(!implicitDeps.empty()) if(!implicitDeps.empty())
{ {
arguments << " |"; arguments += " |";
for(cmNinjaDeps::const_iterator i = implicitDeps.begin(); for(cmNinjaDeps::const_iterator i = implicitDeps.begin();
i != implicitDeps.end(); i != implicitDeps.end();
++i) ++i)
arguments << " " << EncodeIdent(EncodePath(*i), os); arguments += " " + EncodeIdent(EncodePath(*i), os);
} }
// Write order-only dependencies. // Write order-only dependencies.
if(!orderOnlyDeps.empty()) if(!orderOnlyDeps.empty())
{ {
arguments << " ||"; arguments += " ||";
for(cmNinjaDeps::const_iterator i = orderOnlyDeps.begin(); for(cmNinjaDeps::const_iterator i = orderOnlyDeps.begin();
i != orderOnlyDeps.end(); i != orderOnlyDeps.end();
++i) ++i)
arguments << " " << EncodeIdent(EncodePath(*i), os); arguments += " " + EncodeIdent(EncodePath(*i), os);
} }
arguments << "\n"; arguments += "\n";
cmOStringStream build; std::string build;
// Write outputs files. // Write outputs files.
build << "build"; build += "build";
for(cmNinjaDeps::const_iterator i = outputs.begin(); for(cmNinjaDeps::const_iterator i = outputs.begin();
i != outputs.end(); ++i) i != outputs.end(); ++i)
{ {
build << " " << EncodeIdent(EncodePath(*i), os); build += " " + EncodeIdent(EncodePath(*i), os);
this->CombinedBuildOutputs.insert( EncodePath(*i) ); this->CombinedBuildOutputs.insert( EncodePath(*i) );
} }
build << ":"; build += ":";
// Write the rule. // Write the rule.
build << " " << rule; build += " " + rule;
// Write the variables bound to this build statement. // Write the variables bound to this build statement.
cmOStringStream variable_assignments; cmOStringStream variable_assignments;
@ -203,9 +203,9 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
i->first, i->second, "", 1); i->first, i->second, "", 1);
// check if a response file rule should be used // check if a response file rule should be used
std::string buildstr = build.str(); std::string buildstr = build;
std::string assignments = variable_assignments.str(); std::string assignments = variable_assignments.str();
const std::string args = arguments.str(); const std::string& args = arguments;
if (cmdLineLimit > 0 if (cmdLineLimit > 0
&& args.size() + buildstr.size() + assignments.size() && args.size() + buildstr.size() + assignments.size()
> (size_t) cmdLineLimit) { > (size_t) cmdLineLimit) {