summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalGenerator.cxx
diff options
context:
space:
mode:
authorMilian Wolff <mail@milianw.de>2016-01-15 13:17:29 (GMT)
committerStephen Kelly <steveire@gmail.com>2016-01-20 20:20:55 (GMT)
commitf9599ed42f5bfda35b98936257423f00e260498f (patch)
treed6232fedc91e9a4313d7c3ccb4b1d2d2e905010a /Source/cmGlobalGenerator.cxx
parent275f2a85b21d781e237dd22252261a0a62d9879b (diff)
downloadCMake-f9599ed42f5bfda35b98936257423f00e260498f.zip
CMake-f9599ed42f5bfda35b98936257423f00e260498f.tar.gz
CMake-f9599ed42f5bfda35b98936257423f00e260498f.tar.bz2
Remove temporary allocations by extending the lifetime of the retval.
See also Herb Sutter's article on the "most important const": http://herbsutter.com/2008/01/01/gotw-88-a-candidate-for-the-most-important-const/ When running the CMake daemon on the KDevelop build dir, this removes some hundreds of thousands of temporary allocations. This hotspot was found with heaptrack.
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r--Source/cmGlobalGenerator.cxx12
1 files changed, 6 insertions, 6 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 2126c71..b9296c1 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2198,9 +2198,9 @@ cmGlobalGenerator::FindGeneratorTargetImpl(std::string const& name) const
{
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
{
- std::vector<cmGeneratorTarget*> tgts =
+ const std::vector<cmGeneratorTarget*>& tgts =
this->LocalGenerators[i]->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin();
+ for (std::vector<cmGeneratorTarget*>::const_iterator it = tgts.begin();
it != tgts.end(); ++it)
{
if ((*it)->GetName() == name)
@@ -2217,9 +2217,9 @@ cmGlobalGenerator::FindImportedTargetImpl(std::string const& name) const
{
for (unsigned int i = 0; i < this->Makefiles.size(); ++i)
{
- std::vector<cmTarget*> tgts =
+ const std::vector<cmTarget*>& tgts =
this->Makefiles[i]->GetOwnedImportedTargets();
- for (std::vector<cmTarget*>::iterator it = tgts.begin();
+ for (std::vector<cmTarget*>::const_iterator it = tgts.begin();
it != tgts.end(); ++it)
{
if ((*it)->GetName() == name && (*it)->IsImportedGloballyVisible())
@@ -2236,9 +2236,9 @@ cmGeneratorTarget* cmGlobalGenerator::FindImportedGeneratorTargetImpl(
{
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
{
- std::vector<cmGeneratorTarget*> tgts =
+ const std::vector<cmGeneratorTarget*>& tgts =
this->LocalGenerators[i]->GetImportedGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin();
+ for (std::vector<cmGeneratorTarget*>::const_iterator it = tgts.begin();
it != tgts.end(); ++it)
{
if ((*it)->IsImportedGloballyVisible() && (*it)->GetName() == name)