diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2014-03-12 18:25:59 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2014-04-29 20:00:05 (GMT) |
commit | ef62fbad55deedd4b985f0900f1ee983eaa0072d (patch) | |
tree | 5cbdffffdc5db458d387d91f8357596ed78ea7c7 /Source/cmMakefile.cxx | |
parent | f718b30a95e07d72a361d55b7ba495eda5d79680 (diff) | |
download | CMake-ef62fbad55deedd4b985f0900f1ee983eaa0072d.zip CMake-ef62fbad55deedd4b985f0900f1ee983eaa0072d.tar.gz CMake-ef62fbad55deedd4b985f0900f1ee983eaa0072d.tar.bz2 |
ClearMatches: Store match variable names statically
Constructing the names and then turning them into a std::string is
non-negligible in performance testing.
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 262f29d..b71e113 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4332,20 +4332,30 @@ std::vector<cmSourceFile*> cmMakefile::GetQtUiFilesWithOptions() const return this->QtUiFilesWithOptions; } +static std::string matchVariables[] = { + "CMAKE_MATCH_0", + "CMAKE_MATCH_1", + "CMAKE_MATCH_2", + "CMAKE_MATCH_3", + "CMAKE_MATCH_4", + "CMAKE_MATCH_5", + "CMAKE_MATCH_6", + "CMAKE_MATCH_7", + "CMAKE_MATCH_8", + "CMAKE_MATCH_9" +}; + //---------------------------------------------------------------------------- void cmMakefile::ClearMatches() { - std::stringstream sstr; for (unsigned int i=0; i<this->NumLastMatches; i++) { - sstr.str(""); - sstr << "CMAKE_MATCH_" << i; - std::string const& name = sstr.str(); - std::string const& s = this->GetSafeDefinition(name); + std::string const& var = matchVariables[i]; + std::string const& s = this->GetSafeDefinition(var); if(!s.empty()) { - this->AddDefinition(name, ""); - this->MarkVariableAsUsed(name); + this->AddDefinition(var, ""); + this->MarkVariableAsUsed(var); } } this->NumLastMatches = 0; @@ -4359,10 +4369,9 @@ void cmMakefile::StoreMatches(cmsys::RegularExpression& re) std::string m = re.match(i); if(m.size() > 0) { - char name[128]; - sprintf(name, "CMAKE_MATCH_%d", i); - this->AddDefinition(name, re.match(i).c_str()); - this->MarkVariableAsUsed(name); + std::string const& var = matchVariables[i]; + this->AddDefinition(var, re.match(i).c_str()); + this->MarkVariableAsUsed(var); this->NumLastMatches = i + 1; } } |