summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilian Wolff <mail@milianw.de>2016-01-15 13:19:33 (GMT)
committerStephen Kelly <steveire@gmail.com>2016-01-20 20:20:55 (GMT)
commitad9394f4fdb69f3f3376d7377fac0a22568aed7c (patch)
treea1f18c98f0243478be1a3b15d0af683525fcffd8
parentf9599ed42f5bfda35b98936257423f00e260498f (diff)
downloadCMake-ad9394f4fdb69f3f3376d7377fac0a22568aed7c.zip
CMake-ad9394f4fdb69f3f3376d7377fac0a22568aed7c.tar.gz
CMake-ad9394f4fdb69f3f3376d7377fac0a22568aed7c.tar.bz2
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.
-rw-r--r--Source/cmMacroCommand.cxx16
1 files changed, 7 insertions, 9 deletions
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index e4026b0..71de7a7 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -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]);
}
}
}