Remove temporary allocations in cmMacroHelper::InvokeInitialPass.

This code used to convert std::string's to raw C strings only to
put that back into a std::string. This patch thus removes ~70k
temporary allocations when running the CMake daemon on KDevelop.

This hotspot was found with heaptrack.
This commit is contained in:
Milian Wolff 2016-01-15 14:19:33 +01:00 committed by Stephen Kelly
parent f9599ed42f
commit ad9394f4fd

View File

@ -146,16 +146,14 @@ bool cmMacroHelperCommand::InvokeInitialPass
// replace formal arguments
for (unsigned int j = 0; j < variables.size(); ++j)
{
cmSystemTools::ReplaceString(arg.Value, variables[j].c_str(),
expandedArgs[j].c_str());
cmSystemTools::ReplaceString(arg.Value, variables[j],
expandedArgs[j]);
}
// replace argc
cmSystemTools::ReplaceString(arg.Value, "${ARGC}",argcDef.c_str());
cmSystemTools::ReplaceString(arg.Value, "${ARGC}", argcDef);
cmSystemTools::ReplaceString(arg.Value, "${ARGN}",
expandedArgn.c_str());
cmSystemTools::ReplaceString(arg.Value, "${ARGV}",
expandedArgv.c_str());
cmSystemTools::ReplaceString(arg.Value, "${ARGN}", expandedArgn);
cmSystemTools::ReplaceString(arg.Value, "${ARGV}", expandedArgv);
// if the current argument of the current function has ${ARGV in it
// then try replacing ARGV values
@ -163,8 +161,8 @@ bool cmMacroHelperCommand::InvokeInitialPass
{
for (unsigned int t = 0; t < expandedArgs.size(); ++t)
{
cmSystemTools::ReplaceString(arg.Value, argVs[t].c_str(),
expandedArgs[t].c_str());
cmSystemTools::ReplaceString(arg.Value, argVs[t],
expandedArgs[t]);
}
}
}