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