cmMakefile: Use Ranges for buildsystem property access.

Don't return vector copies.
This commit is contained in:
Stephen Kelly 2015-07-18 10:52:09 +02:00
parent 514a1dff5b
commit 8d336875b3
4 changed files with 30 additions and 34 deletions

View File

@ -1417,9 +1417,9 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
{ {
cmMakefile *mf = this->LocalGenerators[i]->GetMakefile(); cmMakefile *mf = this->LocalGenerators[i]->GetMakefile();
const std::vector<std::string> noconfig_compile_definitions = const cmStringRange noconfig_compile_definitions =
mf->GetCompileDefinitionsEntries(); mf->GetCompileDefinitionsEntries();
const std::vector<cmListFileBacktrace> noconfig_compile_definitions_bts = const cmBacktraceRange noconfig_compile_definitions_bts =
mf->GetCompileDefinitionsBacktraces(); mf->GetCompileDefinitionsBacktraces();
cmTargets& targets = mf->GetTargets(); cmTargets& targets = mf->GetTargets();
@ -1435,9 +1435,9 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
continue; continue;
} }
std::vector<cmListFileBacktrace>::const_iterator btIt cmBacktraceRange::const_iterator btIt
= noconfig_compile_definitions_bts.begin(); = noconfig_compile_definitions_bts.begin();
for (std::vector<std::string>::const_iterator it for (cmStringRange::const_iterator it
= noconfig_compile_definitions.begin(); = noconfig_compile_definitions.begin();
it != noconfig_compile_definitions.end(); ++it, ++btIt) it != noconfig_compile_definitions.end(); ++it, ++btIt)
{ {

View File

@ -273,38 +273,34 @@ void cmMakefile::IssueMessage(cmake::MessageType t,
} }
} }
std::vector<std::string> cmMakefile::GetIncludeDirectoriesEntries() const cmStringRange cmMakefile::GetIncludeDirectoriesEntries() const
{ {
return this->IncludeDirectoriesEntries; return cmMakeRange(this->IncludeDirectoriesEntries);
} }
std::vector<cmListFileBacktrace> cmBacktraceRange cmMakefile::GetIncludeDirectoriesBacktraces() const
cmMakefile::GetIncludeDirectoriesBacktraces() const
{ {
return this->IncludeDirectoriesEntryBacktraces; return cmMakeRange(this->IncludeDirectoriesEntryBacktraces);
} }
cmStringRange cmMakefile::GetCompileOptionsEntries() const
std::vector<std::string> cmMakefile::GetCompileOptionsEntries() const
{ {
return this->CompileOptionsEntries; return cmMakeRange(this->CompileOptionsEntries);
} }
std::vector<cmListFileBacktrace> cmBacktraceRange cmMakefile::GetCompileOptionsBacktraces() const
cmMakefile::GetCompileOptionsBacktraces() const
{ {
return this->CompileOptionsEntryBacktraces; return cmMakeRange(this->CompileOptionsEntryBacktraces);
} }
std::vector<std::string> cmMakefile::GetCompileDefinitionsEntries() const cmStringRange cmMakefile::GetCompileDefinitionsEntries() const
{ {
return this->CompileDefinitionsEntries; return cmMakeRange(this->CompileDefinitionsEntries);
} }
std::vector<cmListFileBacktrace> cmBacktraceRange cmMakefile::GetCompileDefinitionsBacktraces() const
cmMakefile::GetCompileDefinitionsBacktraces() const
{ {
return this->CompileDefinitionsEntryBacktraces; return cmMakeRange(this->CompileDefinitionsEntryBacktraces);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -22,6 +22,7 @@
#include "cmExpandedCommandArgument.h" #include "cmExpandedCommandArgument.h"
#include "cmake.h" #include "cmake.h"
#include "cmState.h" #include "cmState.h"
#include "cmAlgorithms.h"
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)
#include "cmSourceGroup.h" #include "cmSourceGroup.h"
@ -746,12 +747,12 @@ public:
/** Set whether or not to report a CMP0000 violation. */ /** Set whether or not to report a CMP0000 violation. */
void SetCheckCMP0000(bool b) { this->CheckCMP0000 = b; } void SetCheckCMP0000(bool b) { this->CheckCMP0000 = b; }
std::vector<std::string> GetIncludeDirectoriesEntries() const; cmStringRange GetIncludeDirectoriesEntries() const;
std::vector<cmListFileBacktrace> GetIncludeDirectoriesBacktraces() const; cmBacktraceRange GetIncludeDirectoriesBacktraces() const;
std::vector<std::string> GetCompileOptionsEntries() const; cmStringRange GetCompileOptionsEntries() const;
std::vector<cmListFileBacktrace> GetCompileOptionsBacktraces() const; cmBacktraceRange GetCompileOptionsBacktraces() const;
std::vector<std::string> GetCompileDefinitionsEntries() const; cmStringRange GetCompileDefinitionsEntries() const;
std::vector<cmListFileBacktrace> GetCompileDefinitionsBacktraces() const; cmBacktraceRange GetCompileDefinitionsBacktraces() const;
bool IsConfigured() const { return this->Configured; } bool IsConfigured() const { return this->Configured; }
void SetConfigured(){ this->Configured = true; } void SetConfigured(){ this->Configured = true; }

View File

@ -402,14 +402,13 @@ void cmTarget::SetMakefile(cmMakefile* mf)
{ {
// Initialize the INCLUDE_DIRECTORIES property based on the current value // Initialize the INCLUDE_DIRECTORIES property based on the current value
// of the same directory property: // of the same directory property:
const std::vector<std::string> parentIncludes = const cmStringRange parentIncludes =
this->Makefile->GetIncludeDirectoriesEntries(); this->Makefile->GetIncludeDirectoriesEntries();
const std::vector<cmListFileBacktrace> parentIncludesBts = const cmBacktraceRange parentIncludesBts =
this->Makefile->GetIncludeDirectoriesBacktraces(); this->Makefile->GetIncludeDirectoriesBacktraces();
std::vector<cmListFileBacktrace>::const_iterator btIt = cmBacktraceRange::const_iterator btIt = parentIncludesBts.begin();
parentIncludesBts.begin(); for (cmStringRange::const_iterator it
for (std::vector<std::string>::const_iterator it
= parentIncludes.begin(); = parentIncludes.begin();
it != parentIncludes.end(); ++it, ++btIt) it != parentIncludes.end(); ++it, ++btIt)
{ {
@ -421,13 +420,13 @@ void cmTarget::SetMakefile(cmMakefile* mf)
this->SystemIncludeDirectories.insert(parentSystemIncludes.begin(), this->SystemIncludeDirectories.insert(parentSystemIncludes.begin(),
parentSystemIncludes.end()); parentSystemIncludes.end());
const std::vector<std::string> parentOptions = const cmStringRange parentOptions =
this->Makefile->GetCompileOptionsEntries(); this->Makefile->GetCompileOptionsEntries();
const std::vector<cmListFileBacktrace> parentOptionsBts = const cmBacktraceRange parentOptionsBts =
this->Makefile->GetCompileOptionsBacktraces(); this->Makefile->GetCompileOptionsBacktraces();
btIt = parentOptionsBts.begin(); btIt = parentOptionsBts.begin();
for (std::vector<std::string>::const_iterator it for (cmStringRange::const_iterator it
= parentOptions.begin(); = parentOptions.begin();
it != parentOptions.end(); ++it, ++btIt) it != parentOptions.end(); ++it, ++btIt)
{ {