This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake".
The branch, next has been updated via 95137add8e3ff19a4e69bfb077f937796a4466e2 (commit) via 3f51752264bc1243fa2e56da41131ac363d3bd85 (commit) via ef62fbad55deedd4b985f0900f1ee983eaa0072d (commit) via f718b30a95e07d72a361d55b7ba495eda5d79680 (commit) from 2afb232456586a2803034dea8c77226fa2a4eeaf (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=95137add8e3ff19a4e69bfb077f937796a4466e2 commit 95137add8e3ff19a4e69bfb077f937796a4466e2 Merge: 2afb232 3f51752 Author: Ben Boeckel <ben.boec...@kitware.com> AuthorDate: Thu May 1 17:11:55 2014 -0400 Commit: CMake Topic Stage <kwro...@kitware.com> CommitDate: Thu May 1 17:11:55 2014 -0400 Merge topic 'dev/regex-variables' into next 3f517522 StoreMatches: Minor cleanups ef62fbad ClearMatches: Store match variable names statically f718b30a ClearMatches: Only clear matches which were actually set http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3f51752264bc1243fa2e56da41131ac363d3bd85 commit 3f51752264bc1243fa2e56da41131ac363d3bd85 Author: Ben Boeckel <ben.boec...@kitware.com> AuthorDate: Wed Mar 12 14:26:45 2014 -0400 Commit: Ben Boeckel <ben.boec...@kitware.com> CommitDate: Tue Apr 29 16:00:06 2014 -0400 StoreMatches: Minor cleanups diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index b71e113..de329f0 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4366,11 +4366,11 @@ void cmMakefile::StoreMatches(cmsys::RegularExpression& re) { for (unsigned int i=0; i<10; i++) { - std::string m = re.match(i); - if(m.size() > 0) + std::string const& m = re.match(i); + if(!m.empty()) { std::string const& var = matchVariables[i]; - this->AddDefinition(var, re.match(i).c_str()); + this->AddDefinition(var, m.c_str()); this->MarkVariableAsUsed(var); this->NumLastMatches = i + 1; } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ef62fbad55deedd4b985f0900f1ee983eaa0072d commit ef62fbad55deedd4b985f0900f1ee983eaa0072d Author: Ben Boeckel <ben.boec...@kitware.com> AuthorDate: Wed Mar 12 14:25:59 2014 -0400 Commit: Ben Boeckel <ben.boec...@kitware.com> CommitDate: Tue Apr 29 16:00:05 2014 -0400 ClearMatches: Store match variable names statically Constructing the names and then turning them into a std::string is non-negligible in performance testing. 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; } } http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f718b30a95e07d72a361d55b7ba495eda5d79680 commit f718b30a95e07d72a361d55b7ba495eda5d79680 Author: Ben Boeckel <ben.boec...@kitware.com> AuthorDate: Wed Mar 12 14:23:12 2014 -0400 Commit: Ben Boeckel <ben.boec...@kitware.com> CommitDate: Tue Apr 29 16:00:05 2014 -0400 ClearMatches: Only clear matches which were actually set ClearMatches was clearing many variables which were never set in the first place. Instead, store how many matches were made last time and only clear those. It is moved to the cmMakefile class since it is a common utility used by multiple commands. diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 06c4b89..1141b01 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -595,7 +595,7 @@ namespace { def = cmIfCommand::GetVariableOrString(*arg, makefile); const char* rex = (argP2)->c_str(); - cmStringCommand::ClearMatches(makefile); + makefile->ClearMatches(); cmsys::RegularExpression regEntry; if ( !regEntry.compile(rex) ) { @@ -607,7 +607,7 @@ namespace } if (regEntry.find(def)) { - cmStringCommand::StoreMatches(makefile, regEntry); + makefile->StoreMatches(regEntry); *arg = "1"; } else diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 07cfe12..262f29d 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -148,6 +148,8 @@ cmMakefile::cmMakefile(): Internal(new Internals) this->Initialize(); this->PreOrder = false; this->GeneratingBuildSystem = false; + + this->NumLastMatches = 0; } cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals) @@ -196,6 +198,8 @@ cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals) this->CheckSystemVars = mf.CheckSystemVars; this->ListFileStack = mf.ListFileStack; this->OutputToSource = mf.OutputToSource; + + this->NumLastMatches = mf.NumLastMatches; } //---------------------------------------------------------------------------- @@ -4329,6 +4333,42 @@ std::vector<cmSourceFile*> cmMakefile::GetQtUiFilesWithOptions() const } //---------------------------------------------------------------------------- +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); + if(!s.empty()) + { + this->AddDefinition(name, ""); + this->MarkVariableAsUsed(name); + } + } + this->NumLastMatches = 0; +} + +//---------------------------------------------------------------------------- +void cmMakefile::StoreMatches(cmsys::RegularExpression& re) +{ + for (unsigned int i=0; i<10; i++) + { + 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); + this->NumLastMatches = i + 1; + } + } +} + +//---------------------------------------------------------------------------- cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 3bccb63..7d1759e 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -889,6 +889,9 @@ public: const std::string& feature, std::string *error = 0) const; + void ClearMatches(); + void StoreMatches(cmsys::RegularExpression& re); + protected: // add link libraries and directories to the target void AddGlobalLinkInformation(const std::string& name, cmTarget& target); @@ -1065,6 +1068,8 @@ private: cmSourceFile* source); std::vector<cmSourceFile*> QtUiFilesWithOptions; + + unsigned int NumLastMatches; }; //---------------------------------------------------------------------------- diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index ea762eb..65912da 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -305,7 +305,7 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args) input += args[i]; } - this->ClearMatches(this->Makefile); + this->Makefile->ClearMatches(); // Compile the regular expression. cmsys::RegularExpression re; if(!re.compile(regex.c_str())) @@ -320,7 +320,7 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args) std::string output; if(re.find(input.c_str())) { - this->StoreMatches(this->Makefile, re); + this->Makefile->StoreMatches(re); std::string::size_type l = re.start(); std::string::size_type r = re.end(); if(r-l == 0) @@ -354,7 +354,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args) input += args[i]; } - this->ClearMatches(this->Makefile); + this->Makefile->ClearMatches(); // Compile the regular expression. cmsys::RegularExpression re; if(!re.compile(regex.c_str())) @@ -371,7 +371,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args) const char* p = input.c_str(); while(re.find(p)) { - this->StoreMatches(this->Makefile, re); + this->Makefile->StoreMatches(re); std::string::size_type l = re.start(); std::string::size_type r = re.end(); if(r-l == 0) @@ -458,7 +458,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args) input += args[i]; } - this->ClearMatches(this->Makefile); + this->Makefile->ClearMatches(); // Compile the regular expression. cmsys::RegularExpression re; if(!re.compile(regex.c_str())) @@ -475,7 +475,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args) std::string::size_type base = 0; while(re.find(input.c_str()+base)) { - this->StoreMatches(this->Makefile, re); + this->Makefile->StoreMatches(re); std::string::size_type l2 = re.start(); std::string::size_type r = re.end(); @@ -536,38 +536,6 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args) } //---------------------------------------------------------------------------- -void cmStringCommand::ClearMatches(cmMakefile* mf) -{ - for (unsigned int i=0; i<10; i++) - { - char name[128]; - sprintf(name, "CMAKE_MATCH_%d", i); - const char* s = mf->GetDefinition(name); - if(s && *s != 0) - { - mf->AddDefinition(name, ""); - mf->MarkVariableAsUsed(name); - } - } -} - -//---------------------------------------------------------------------------- -void cmStringCommand::StoreMatches(cmMakefile* mf,cmsys::RegularExpression& re) -{ - for (unsigned int i=0; i<10; i++) - { - std::string m = re.match(i); - if(m.size() > 0) - { - char name[128]; - sprintf(name, "CMAKE_MATCH_%d", i); - mf->AddDefinition(name, re.match(i).c_str()); - mf->MarkVariableAsUsed(name); - } - } -} - -//---------------------------------------------------------------------------- bool cmStringCommand::HandleFindCommand(std::vector<std::string> const& args) { diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h index 51069e7..8292e64 100644 --- a/Source/cmStringCommand.h +++ b/Source/cmStringCommand.h @@ -53,8 +53,6 @@ public: virtual std::string GetName() const { return "string";} cmTypeMacro(cmStringCommand, cmCommand); - static void ClearMatches(cmMakefile* mf); - static void StoreMatches(cmMakefile* mf, cmsys::RegularExpression& re); protected: bool HandleConfigureCommand(std::vector<std::string> const& args); bool HandleAsciiCommand(std::vector<std::string> const& args); ----------------------------------------------------------------------- Summary of changes: Source/cmIfCommand.cxx | 4 ++-- Source/cmMakefile.cxx | 49 ++++++++++++++++++++++++++++++++++++++++++++ Source/cmMakefile.h | 5 +++++ Source/cmStringCommand.cxx | 44 ++++++--------------------------------- Source/cmStringCommand.h | 2 -- 5 files changed, 62 insertions(+), 42 deletions(-) hooks/post-receive -- CMake _______________________________________________ Cmake-commits mailing list Cmake-commits@cmake.org http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-commits