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 f2f5d3086d2eecec219e26740e0bcb556e3dd133 (commit) via 068358e1edd4ed0c19a40f3be16edb64123f45ee (commit) from 356a3f60095d1f5132f590833737fed4db766580 (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 ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f2f5d3086d2eecec219e26740e0bcb556e3dd133 commit f2f5d3086d2eecec219e26740e0bcb556e3dd133 Merge: 356a3f6 068358e Author: Rolf Eike Beer <e...@sf-mail.de> AuthorDate: Wed Apr 20 17:33:45 2016 -0400 Commit: CMake Topic Stage <kwro...@kitware.com> CommitDate: Wed Apr 20 17:33:45 2016 -0400 Merge topic 'addcachedefinitions-convert' into next 068358e1 cmMakefile::AddCacheDefinition: avoid conversions between char* and string https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=068358e1edd4ed0c19a40f3be16edb64123f45ee commit 068358e1edd4ed0c19a40f3be16edb64123f45ee Author: Rolf Eike Beer <e...@sf-mail.de> AuthorDate: Wed Apr 20 22:40:58 2016 +0200 Commit: Rolf Eike Beer <e...@sf-mail.de> CommitDate: Wed Apr 20 23:33:17 2016 +0200 cmMakefile::AddCacheDefinition: avoid conversions between char* and string Running the testsuite this function is entered more than 126,000 times. Reorder the code flow so that a conversion from char* to std::string is only done when the cache entry is a path one, which happens only ~50 times during the testsuite. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 3a56c2a..f01ff74 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1824,10 +1824,11 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, cmState::CacheEntryType type, bool force) { - bool haveVal = value ? true : false; - std::string val = haveVal ? value : ""; const char* existingValue = this->GetState()->GetInitializedCacheValue(name); + // must be outside the following if() to keep it alive long enough + std::string nvalue; + if(existingValue && (this->GetState()->GetCacheEntryType(name) == cmState::UNINITIALIZED)) @@ -1836,15 +1837,16 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, // if it is a force, then use the value being passed in if(!force) { - val = existingValue; - haveVal = true; + value = existingValue; } if ( type == cmState::PATH || type == cmState::FILEPATH ) { std::vector<std::string>::size_type cc; std::vector<std::string> files; - std::string nvalue = ""; - cmSystemTools::ExpandListArgument(val, files); + nvalue = value ? value : ""; + + cmSystemTools::ExpandListArgument(nvalue, files); + nvalue = ""; for ( cc = 0; cc < files.size(); cc ++ ) { if(!cmSystemTools::IsOff(files[cc].c_str())) @@ -1859,13 +1861,12 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, } this->GetCMakeInstance()->AddCacheEntry(name, nvalue.c_str(), doc, type); - val = this->GetState()->GetInitializedCacheValue(name); - haveVal = true; + nvalue = this->GetState()->GetInitializedCacheValue(name); + value = nvalue.c_str(); } } - this->GetCMakeInstance()->AddCacheEntry(name, haveVal ? val.c_str() : 0, - doc, type); + this->GetCMakeInstance()->AddCacheEntry(name, value, doc, type); // if there was a definition then remove it this->StateSnapshot.RemoveDefinition(name); } ----------------------------------------------------------------------- Summary of changes: Source/cmMakefile.cxx | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) hooks/post-receive -- CMake _______________________________________________ Cmake-commits mailing list Cmake-commits@cmake.org http://public.kitware.com/mailman/listinfo/cmake-commits