From 421eadb45b48d40aa7d0b5e42a48df4ba94b9fc0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 29 Jan 2015 23:19:40 +0100 Subject: Remove use of cmsys_stl. It is not needed. --- Source/CPack/OSXScriptLauncher.cxx | 8 ++++---- Source/CPack/cmCPackNSISGenerator.cxx | 2 +- Source/CTest/cmCTestCoverageHandler.cxx | 4 ++-- Source/QtDialog/CMakeSetup.cxx | 6 +++--- Source/cmComputeLinkDepends.cxx | 6 +++--- Source/cmFileCommand.cxx | 4 ++-- Source/cmFindLibraryCommand.cxx | 4 ++-- Source/cmSystemTools.cxx | 2 +- Source/cmXMLSafe.cxx | 4 ++-- Source/cmXMLSafe.h | 4 ++-- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Source/CPack/OSXScriptLauncher.cxx b/Source/CPack/OSXScriptLauncher.cxx index d9d6236..1d7afbd 100644 --- a/Source/CPack/OSXScriptLauncher.cxx +++ b/Source/CPack/OSXScriptLauncher.cxx @@ -26,7 +26,7 @@ int main(int argc, char* argv[]) { //if ( cmsys::SystemTools::FileExists( - cmsys_stl::string cwd = cmsys::SystemTools::GetCurrentWorkingDirectory(); + std::string cwd = cmsys::SystemTools::GetCurrentWorkingDirectory(); cmsys::ofstream ofs("/tmp/output.txt"); CFStringRef fileName; @@ -66,7 +66,7 @@ int main(int argc, char* argv[]) //dispose of the CF variable CFRelease(scriptFileURL); - cmsys_stl::string fullScriptPath = reinterpret_cast(path); + std::string fullScriptPath = reinterpret_cast(path); delete [] path; @@ -75,10 +75,10 @@ int main(int argc, char* argv[]) return 1; } - cmsys_stl::string scriptDirectory = cmsys::SystemTools::GetFilenamePath( + std::string scriptDirectory = cmsys::SystemTools::GetFilenamePath( fullScriptPath); ofs << fullScriptPath.c_str() << cmsys_ios::endl; - cmsys_stl::vector args; + std::vector args; args.push_back(fullScriptPath.c_str()); int cc; for ( cc = 1; cc < argc; ++ cc ) diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 8f63ca2..fe6cc95 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -654,7 +654,7 @@ bool cmCPackNSISGenerator::GetListOfSubdirectories(const char* topdir, if (strcmp(dir.GetFile(static_cast(fileNum)),".") && strcmp(dir.GetFile(static_cast(fileNum)),"..")) { - cmsys_stl::string fullPath = topdir; + std::string fullPath = topdir; fullPath += "/"; fullPath += dir.GetFile(static_cast(fileNum)); if(cmsys::SystemTools::FileIsDirectory(fullPath) && diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 08b7c66..1226d22 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -2542,10 +2542,10 @@ bool cmCTestCoverageHandler::IntersectsFilter(LabelSet const& labels) } std::vector ids; - cmsys_stl::set_intersection + std::set_intersection (labels.begin(), labels.end(), this->LabelFilter.begin(), this->LabelFilter.end(), - cmsys_stl::back_inserter(ids)); + std::back_inserter(ids)); return !ids.empty(); } diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 82fa3a3..8a72a24 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -149,10 +149,10 @@ int main(int argc, char** argv) QStringList args = app.arguments(); if(args.count() == 2) { - cmsys_stl::string filePath = cmSystemTools::CollapseFullPath(args[1].toLocal8Bit().data()); + std::string filePath = cmSystemTools::CollapseFullPath(args[1].toLocal8Bit().data()); // check if argument is a directory containing CMakeCache.txt - cmsys_stl::string buildFilePath = + std::string buildFilePath = cmSystemTools::CollapseFullPath("CMakeCache.txt", filePath.c_str()); // check if argument is a CMakeCache.txt file @@ -163,7 +163,7 @@ int main(int argc, char** argv) } // check if argument is a directory containing CMakeLists.txt - cmsys_stl::string srcFilePath = + std::string srcFilePath = cmSystemTools::CollapseFullPath("CMakeLists.txt", filePath.c_str()); if(cmSystemTools::FileExists(buildFilePath.c_str())) diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 32d5cd3..fa1bbcc 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -669,7 +669,7 @@ void cmComputeLinkDepends::InferDependencies() for(++i; i != sets->end(); ++i) { DependSet intersection; - cmsys_stl::set_intersection + std::set_intersection (common.begin(), common.end(), i->begin(), i->end(), std::inserter(intersection, intersection.begin())); common = intersection; @@ -689,10 +689,10 @@ void cmComputeLinkDepends::CleanConstraintGraph() { // Sort the outgoing edges for each graph node so that the // original order will be preserved as much as possible. - cmsys_stl::sort(i->begin(), i->end()); + std::sort(i->begin(), i->end()); // Make the edge list unique. - EdgeList::iterator last = cmsys_stl::unique(i->begin(), i->end()); + EdgeList::iterator last = std::unique(i->begin(), i->end()); i->erase(last, i->end()); } } diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 579e715..8b893bc 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -71,7 +71,7 @@ static std::string fix_file_url_windows(const std::string& url) std::string ret = url; if(strncmp(url.c_str(), "file://", 7) == 0) { - cmsys_stl::wstring wurl = cmsys::Encoding::ToWide(url); + std::wstring wurl = cmsys::Encoding::ToWide(url); if(!wurl.empty()) { int mblen = WideCharToMultiByte(CP_ACP, 0, wurl.c_str(), -1, @@ -1843,7 +1843,7 @@ bool cmFileCopier::InstallDirectory(const char* source, if(!(strcmp(dir.GetFile(fileNum), ".") == 0 || strcmp(dir.GetFile(fileNum), "..") == 0)) { - cmsys_stl::string fromPath = source; + std::string fromPath = source; fromPath += "/"; fromPath += dir.GetFile(fileNum); std::string toPath = destination; diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 78f0e9e..c499f61 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -195,12 +195,12 @@ struct cmFindLibraryHelper void RegexFromList(std::string& out, std::vector const& in); size_type GetPrefixIndex(std::string const& prefix) { - return cmsys_stl::find(this->Prefixes.begin(), this->Prefixes.end(), + return std::find(this->Prefixes.begin(), this->Prefixes.end(), prefix) - this->Prefixes.begin(); } size_type GetSuffixIndex(std::string const& suffix) { - return cmsys_stl::find(this->Suffixes.begin(), this->Suffixes.end(), + return std::find(this->Suffixes.begin(), this->Suffixes.end(), suffix) - this->Suffixes.begin(); } bool HasValidSuffix(std::string const& name); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index e9735ed..b07dd78 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2695,7 +2695,7 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg, } if(se_count == 2 && se[1]->IndexInSection < se[0]->IndexInSection) { - cmsys_stl::swap(se[0], se[1]); + std::swap(se[0], se[1]); } // Get the size of the dynamic section header. diff --git a/Source/cmXMLSafe.cxx b/Source/cmXMLSafe.cxx index 72fdc34..99f5625 100644 --- a/Source/cmXMLSafe.cxx +++ b/Source/cmXMLSafe.cxx @@ -28,7 +28,7 @@ cmXMLSafe::cmXMLSafe(const char* s): } //---------------------------------------------------------------------------- -cmXMLSafe::cmXMLSafe(cmsys_stl::string const& s): +cmXMLSafe::cmXMLSafe(std::string const& s): Data(s.c_str()), Size(static_cast(s.length())), DoQuotes(true) @@ -43,7 +43,7 @@ cmXMLSafe& cmXMLSafe::Quotes(bool b) } //---------------------------------------------------------------------------- -cmsys_stl::string cmXMLSafe::str() +std::string cmXMLSafe::str() { cmsys_ios::ostringstream ss; ss << *this; diff --git a/Source/cmXMLSafe.h b/Source/cmXMLSafe.h index cba9f39..c23a90c 100644 --- a/Source/cmXMLSafe.h +++ b/Source/cmXMLSafe.h @@ -24,7 +24,7 @@ public: /** Construct with the data to be written. This assumes the data will exist for the duration of this object's life. */ cmXMLSafe(const char* s); - cmXMLSafe(cmsys_stl::string const& s); + cmXMLSafe(std::string const& s); /** Specify whether to escape quotes too. This is needed when writing the content of an attribute value. By default quotes @@ -32,7 +32,7 @@ public: cmXMLSafe& Quotes(bool b = true); /** Get the escaped data as a string. */ - cmsys_stl::string str(); + std::string str(); private: char const* Data; unsigned long Size; -- cgit v0.12 From 5fc53f1edb2d003595ef224b31a805c3af0dc0e6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 24 Jan 2015 18:12:48 +0100 Subject: cmLocalGenerator: Replace loop with find_first_not_of --- Source/cmLocalGenerator.cxx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7ca7684..9109db4 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -3204,11 +3204,7 @@ cmLocalGenerator std::string ssin = sin; // Avoid full paths by removing leading slashes. - std::string::size_type pos = 0; - for(;pos < ssin.size() && ssin[pos] == '/'; ++pos) - { - } - ssin = ssin.substr(pos); + ssin.erase(0, ssin.find_first_not_of("/")); // Avoid full paths by removing colons. cmSystemTools::ReplaceString(ssin, ":", "_"); -- cgit v0.12 From bd990c803b40e1532cab6b29c75414ca6f30e782 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 18 Jan 2015 17:10:03 +0100 Subject: Remove use of ExpandSourceListArguments. By now, it is only an expensive copy. --- Source/cmCPluginAPI.cxx | 7 +++---- Source/cmFLTKWrapUICommand.cxx | 7 ++----- Source/cmInstallFilesCommand.cxx | 7 ++----- Source/cmQTWrapCPPCommand.cxx | 10 +++------- Source/cmQTWrapUICommand.cxx | 10 +++------- 5 files changed, 13 insertions(+), 28 deletions(-) diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index d0dc30a..691d80d 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -438,15 +438,14 @@ void CCONV cmExpandSourceListArguments(void *arg, char ***resArgv, unsigned int startArgumentIndex) { - cmMakefile *mf = static_cast(arg); + (void)arg; + (void)startArgumentIndex; std::vector result; - std::vector args2; int i; for (i = 0; i < numArgs; ++i) { - args2.push_back(args[i]); + result.push_back(args[i]); } - mf->ExpandSourceListArguments(args2, result, startArgumentIndex); int resargc = static_cast(result.size()); char **resargv = 0; if (resargc) diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index f7d8243..488beaa 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -31,9 +31,6 @@ bool cmFLTKWrapUICommand // get parameter for the command this->Target = args[0]; // Target that will use the generated files - std::vector newArgs; - this->Makefile->ExpandSourceListArguments(args,newArgs, 1); - // get the list of GUI files from which .cxx and .h will be generated std::string outputDirectory = this->Makefile->GetCurrentOutputDirectory(); @@ -45,8 +42,8 @@ bool cmFLTKWrapUICommand this->Makefile->AddIncludeDirectories( outputDirectories ); } - for(std::vector::iterator i = (newArgs.begin() + 1); - i != newArgs.end(); i++) + for(std::vector::const_iterator i = (args.begin() + 1); + i != args.end(); i++) { cmSourceFile *curr = this->Makefile->GetSource(*i); // if we should use the source GUI diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index 06a78e5..85e5345 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -15,9 +15,9 @@ // cmExecutableCommand bool cmInstallFilesCommand -::InitialPass(std::vector const& argsIn, cmExecutionStatus &) +::InitialPass(std::vector const& args, cmExecutionStatus &) { - if(argsIn.size() < 2) + if(args.size() < 2) { this->SetError("called with incorrect number of arguments"); return false; @@ -27,9 +27,6 @@ bool cmInstallFilesCommand this->Makefile->GetLocalGenerator() ->GetGlobalGenerator()->EnableInstallTarget(); - std::vector args; - this->Makefile->ExpandSourceListArguments(argsIn, args, 2); - this->Destination = args[0]; if((args.size() > 1) && (args[1] == "FILES")) diff --git a/Source/cmQTWrapCPPCommand.cxx b/Source/cmQTWrapCPPCommand.cxx index a984260..878562c 100644 --- a/Source/cmQTWrapCPPCommand.cxx +++ b/Source/cmQTWrapCPPCommand.cxx @@ -12,19 +12,15 @@ #include "cmQTWrapCPPCommand.h" // cmQTWrapCPPCommand -bool cmQTWrapCPPCommand::InitialPass(std::vector const& argsIn, +bool cmQTWrapCPPCommand::InitialPass(std::vector const& args, cmExecutionStatus &) { - if(argsIn.size() < 3 ) + if(args.size() < 3 ) { this->SetError("called with incorrect number of arguments"); return false; } - // This command supports source list inputs for compatibility. - std::vector args; - this->Makefile->ExpandSourceListArguments(argsIn, args, 2); - // Get the moc executable to run in the custom command. const char* moc_exe = this->Makefile->GetRequiredDefinition("QT_MOC_EXECUTABLE"); @@ -35,7 +31,7 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector const& argsIn, this->Makefile->GetSafeDefinition(sourceList); // Create a rule for all sources listed. - for(std::vector::iterator j = (args.begin() + 2); + for(std::vector::const_iterator j = (args.begin() + 2); j != args.end(); ++j) { cmSourceFile *curr = this->Makefile->GetSource(*j); diff --git a/Source/cmQTWrapUICommand.cxx b/Source/cmQTWrapUICommand.cxx index dce59ef..9b92b1e 100644 --- a/Source/cmQTWrapUICommand.cxx +++ b/Source/cmQTWrapUICommand.cxx @@ -12,19 +12,15 @@ #include "cmQTWrapUICommand.h" // cmQTWrapUICommand -bool cmQTWrapUICommand::InitialPass(std::vector const& argsIn, +bool cmQTWrapUICommand::InitialPass(std::vector const& args, cmExecutionStatus &) { - if(argsIn.size() < 4 ) + if(args.size() < 4 ) { this->SetError("called with incorrect number of arguments"); return false; } - // This command supports source list inputs for compatibility. - std::vector args; - this->Makefile->ExpandSourceListArguments(argsIn, args, 3); - // Get the uic and moc executables to run in the custom commands. const char* uic_exe = this->Makefile->GetRequiredDefinition("QT_UIC_EXECUTABLE"); @@ -40,7 +36,7 @@ bool cmQTWrapUICommand::InitialPass(std::vector const& argsIn, this->Makefile->GetSafeDefinition(sourceList); // Create rules for all sources listed. - for(std::vector::iterator j = (args.begin() + 3); + for(std::vector::const_iterator j = (args.begin() + 3); j != args.end(); ++j) { cmSourceFile *curr = this->Makefile->GetSource(*j); -- cgit v0.12 From 3f3db74413fc6b0afe4aa484c0ada2d5271ef0ba Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 25 Jan 2015 14:26:57 +0100 Subject: cmMakefile: Remove ExpandSourceListArguments. --- Source/cmMakefile.cxx | 13 ------------- Source/cmMakefile.h | 11 ----------- 2 files changed, 24 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ba914e1..e709b9f 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3576,19 +3576,6 @@ void cmMakefile::EnableLanguage(std::vector const & lang, optional); } -void cmMakefile::ExpandSourceListArguments( - std::vector const& arguments, - std::vector& newargs, unsigned int /* start */) const -{ - // now expand the args - unsigned int i; - for(i = 0; i < arguments.size(); ++i) - { - // List expansion will have been done already. - newargs.push_back(arguments[i]); - } -} - int cmMakefile::TryCompile(const std::string& srcdir, const std::string& bindir, const std::string& projectName, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index bff8c12..5f22485 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -599,17 +599,6 @@ public: */ void AddSystemIncludeDirectories(const std::set &incs); - /** Expand out any arguements in the vector that have ; separated - * strings into multiple arguements. A new vector is created - * containing the expanded versions of all arguments in argsIn. - * This method differes from the one in cmSystemTools in that if - * the CmakeLists file is version 1.2 or earlier it will check for - * source lists being used without ${} around them - */ - void ExpandSourceListArguments(std::vector const& argsIn, - std::vector& argsOut, - unsigned int startArgumentIndex) const; - /** Get a cmSourceFile pointer for a given source name, if the name is * not found, then a null pointer is returned. */ -- cgit v0.12 From d59913f001b6eb74f9baf8bad183dc83d5e7bcd1 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 18 Jan 2015 15:59:03 +0100 Subject: Take computation out of loop. --- Source/cmLocalUnixMakefileGenerator3.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index fbf2140..13c47c5 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -2393,11 +2393,13 @@ void cmLocalUnixMakefileGenerator3 // On UNIX we must construct a single shell command to change // directory and build because make resets the directory between // each command. + std::string outputForExisting = + this->ConvertToOutputForExisting(tgtDir, relRetDir); std::vector::iterator i = commands.begin(); for (; i != commands.end(); ++i) { std::string cmd = cd_cmd; - cmd += this->ConvertToOutputForExisting(tgtDir, relRetDir); + cmd += outputForExisting; cmd += " && "; cmd += *i; *i = cmd; -- cgit v0.12 From d46c4f0727acb35963dfda579cd5c9efd63aab01 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 25 Jan 2015 15:07:27 +0100 Subject: Extract a prefix variable from loop. --- Source/cmLocalUnixMakefileGenerator3.cxx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 13c47c5..9a2186b 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -2395,14 +2395,11 @@ void cmLocalUnixMakefileGenerator3 // each command. std::string outputForExisting = this->ConvertToOutputForExisting(tgtDir, relRetDir); + std::string prefix = cd_cmd + outputForExisting + " && "; std::vector::iterator i = commands.begin(); for (; i != commands.end(); ++i) { - std::string cmd = cd_cmd; - cmd += outputForExisting; - cmd += " && "; - cmd += *i; - *i = cmd; + *i = prefix + *i; } } } -- cgit v0.12 From a7fcc148bdfa5e9f2c6901b0de8192f5aa043741 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 18 Jan 2015 16:01:54 +0100 Subject: Convert loop to algorithm. --- Source/cmLocalUnixMakefileGenerator3.cxx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 9a2186b..785d0ca 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -2396,10 +2396,7 @@ void cmLocalUnixMakefileGenerator3 std::string outputForExisting = this->ConvertToOutputForExisting(tgtDir, relRetDir); std::string prefix = cd_cmd + outputForExisting + " && "; - std::vector::iterator i = commands.begin(); - for (; i != commands.end(); ++i) - { - *i = prefix + *i; - } + std::transform(commands.begin(), commands.end(), commands.begin(), + std::bind1st(std::plus(), prefix)); } } -- cgit v0.12 From 39622c995c189b4e22dfdc0e9aa29c8fce5eac17 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 24 Jan 2015 18:18:56 +0100 Subject: Convert while loop to member insert. --- Source/cmAddLibraryCommand.cxx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index db2f6fb..edf82bd 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -435,11 +435,7 @@ bool cmAddLibraryCommand cmSystemTools::Message(msg.c_str() ,"Warning"); } - while (s != args.end()) - { - srclists.push_back(*s); - ++s; - } + srclists.insert(srclists.end(), s, args.end()); this->Makefile->AddLibrary(libName, type, srclists, excludeFromAll); -- cgit v0.12 From 71d47115d009983665d6db4b25ea0ef40464f365 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 24 Jan 2015 18:21:56 +0100 Subject: Use insert member instead of back_inserter. --- Source/cmTarget.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 98cb75c..ef42b38 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5919,8 +5919,7 @@ cmTarget::GetCompatibleInterfaces(std::string const& config) const { \ std::vector props; \ cmSystemTools::ExpandListArgument(prop, props); \ - std::copy(props.begin(), props.end(), \ - std::inserter(compat.Props##x, compat.Props##x.begin())); \ + compat.Props##x.insert(props.begin(), props.end()); \ } CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool) CM_READ_COMPATIBLE_INTERFACE(STRING, String) -- cgit v0.12 From 74c4d9d27aece9a619eaab330ad23cf4b0de2b19 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 25 Jan 2015 15:35:26 +0100 Subject: Take a size check outside of an inner loop. --- Source/cmSetTargetPropertiesCommand.cxx | 10 +++++----- Source/cmSetTestsPropertiesCommand.cxx | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx index aeb8077..9a7fab2 100644 --- a/Source/cmSetTargetPropertiesCommand.cxx +++ b/Source/cmSetTargetPropertiesCommand.cxx @@ -35,15 +35,15 @@ bool cmSetTargetPropertiesCommand doingFiles = false; // now loop through the rest of the arguments, new style ++j; + if (std::distance(j, args.end()) % 2 != 0) + { + this->SetError("called with incorrect number of arguments."); + return false; + } while (j != args.end()) { propertyPairs.push_back(*j); ++j; - if(j == args.end()) - { - this->SetError("called with incorrect number of arguments."); - return false; - } propertyPairs.push_back(*j); ++j; } diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx index e66d13d..032c78e 100644 --- a/Source/cmSetTestsPropertiesCommand.cxx +++ b/Source/cmSetTestsPropertiesCommand.cxx @@ -36,15 +36,15 @@ bool cmSetTestsPropertiesCommand doingFiles = false; // now loop through the rest of the arguments, new style ++j; + if (std::distance(j, args.end()) % 2 != 0) + { + this->SetError("called with incorrect number of arguments."); + return false; + } while (j != args.end()) { propertyPairs.push_back(*j); ++j; - if(j == args.end()) - { - this->SetError("called with incorrect number of arguments."); - return false; - } propertyPairs.push_back(*j); ++j; } -- cgit v0.12 From 63f584b618b3381ad93c901f691191acd48329a7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 25 Jan 2015 15:36:59 +0100 Subject: Replace while loop with member insert. --- Source/cmSetTargetPropertiesCommand.cxx | 9 +-------- Source/cmSetTestsPropertiesCommand.cxx | 9 +-------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx index 9a7fab2..e41a0ca 100644 --- a/Source/cmSetTargetPropertiesCommand.cxx +++ b/Source/cmSetTargetPropertiesCommand.cxx @@ -40,14 +40,7 @@ bool cmSetTargetPropertiesCommand this->SetError("called with incorrect number of arguments."); return false; } - while (j != args.end()) - { - propertyPairs.push_back(*j); - ++j; - propertyPairs.push_back(*j); - ++j; - } - // break out of the loop because j is already == end + propertyPairs.insert(propertyPairs.end(), j, args.end()); break; } else if (doingFiles) diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx index 032c78e..d079a19 100644 --- a/Source/cmSetTestsPropertiesCommand.cxx +++ b/Source/cmSetTestsPropertiesCommand.cxx @@ -41,14 +41,7 @@ bool cmSetTestsPropertiesCommand this->SetError("called with incorrect number of arguments."); return false; } - while (j != args.end()) - { - propertyPairs.push_back(*j); - ++j; - propertyPairs.push_back(*j); - ++j; - } - // break out of the loop because j is already == end + propertyPairs.insert(propertyPairs.end(), j, args.end()); break; } else if (doingFiles) -- cgit v0.12 From 683fafea088c26658283da3bdf05277aaa1a3cee Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 25 Jan 2015 16:01:07 +0100 Subject: Replace a loop with std::transform. --- Source/cmake.cxx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 652e451..875dbbd 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2731,11 +2731,10 @@ std::vector const& cmake::GetDebugConfigs() { // Expand the specified list and convert to upper-case. cmSystemTools::ExpandListArgument(config_list, this->DebugConfigs); - for(std::vector::iterator i = this->DebugConfigs.begin(); - i != this->DebugConfigs.end(); ++i) - { - *i = cmSystemTools::UpperCase(*i); - } + std::transform(this->DebugConfigs.begin(), + this->DebugConfigs.end(), + this->DebugConfigs.begin(), + cmSystemTools::UpperCase); } // If no configurations were specified, use a default list. if(this->DebugConfigs.empty()) -- cgit v0.12 From 69dbe51b08bd6b4564d031d78034633f55ed4593 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 25 Jan 2015 16:02:46 +0100 Subject: Replace loop with algorithm. --- Source/cmTarget.cxx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ef42b38..f0bdea7 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1153,15 +1153,11 @@ cmTarget::LinkLibraryType cmTarget::ComputeLinkType( // Check if any entry in the list matches this configuration. std::string configUpper = cmSystemTools::UpperCase(config); - for(std::vector::const_iterator i = debugConfigs.begin(); - i != debugConfigs.end(); ++i) + if (std::find(debugConfigs.begin(), debugConfigs.end(), configUpper) != + debugConfigs.end()) { - if(*i == configUpper) - { - return cmTarget::DEBUG; - } + return cmTarget::DEBUG; } - // The current configuration is not a debug configuration. return cmTarget::OPTIMIZED; } -- cgit v0.12 From 94e993a0c170cf84da9ddb026dfec9d8d99304e0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 27 Jan 2015 21:34:01 +0100 Subject: cmComputeLinkDepends: Remove temporary iterator copy. --- Source/cmComputeLinkDepends.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index fa1bbcc..8652690 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -692,8 +692,7 @@ void cmComputeLinkDepends::CleanConstraintGraph() std::sort(i->begin(), i->end()); // Make the edge list unique. - EdgeList::iterator last = std::unique(i->begin(), i->end()); - i->erase(last, i->end()); + i->erase(std::unique(i->begin(), i->end()), i->end()); } } -- cgit v0.12 From 6cd2ee9524e501a4ef9dc481b469b91f8f022dc9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 27 Jan 2015 22:09:17 +0100 Subject: Replace loop with member algorithm. --- Source/cmLocalGenerator.cxx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 9109db4..bd9cb26 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -3642,14 +3642,13 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const { // Many compilers do not support -DNAME(arg)=sdf so we disable it. bool function_style = false; - for(const char* c = define.c_str(); *c && *c != '='; ++c) + + std::string::size_type pos = define.find_first_of("(="); + if (pos != std::string::npos) { - if(*c == '(') - { - function_style = true; - break; - } + function_style = define[pos] == '('; } + if(function_style) { std::ostringstream e; -- cgit v0.12 From 11093a03e064e1b7ef2d5db28845b5da7b934806 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 27 Jan 2015 22:13:45 +0100 Subject: Replace temporary bool by inlining warning condition. --- Source/cmLocalGenerator.cxx | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index bd9cb26..7afe05f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -3641,24 +3641,20 @@ bool cmLocalGenerator::NeedBackwardsCompatibility_2_4() bool cmLocalGenerator::CheckDefinition(std::string const& define) const { // Many compilers do not support -DNAME(arg)=sdf so we disable it. - bool function_style = false; - std::string::size_type pos = define.find_first_of("(="); if (pos != std::string::npos) { - function_style = define[pos] == '('; - } - - if(function_style) - { - std::ostringstream e; - e << "WARNING: Function-style preprocessor definitions may not be " - << "passed on the compiler command line because many compilers " - << "do not support it.\n" - << "CMake is dropping a preprocessor definition: " << define << "\n" - << "Consider defining the macro in a (configured) header file.\n"; - cmSystemTools::Message(e.str().c_str()); - return false; + if (define[pos] == '(') + { + std::ostringstream e; + e << "WARNING: Function-style preprocessor definitions may not be " + << "passed on the compiler command line because many compilers " + << "do not support it.\n" + << "CMake is dropping a preprocessor definition: " << define << "\n" + << "Consider defining the macro in a (configured) header file.\n"; + cmSystemTools::Message(e.str().c_str()); + return false; + } } // Many compilers do not support # in the value so we disable it. -- cgit v0.12 From 803317aab622e4f12e7d342be5bbb4f16b088efd Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 27 Jan 2015 23:50:42 +0100 Subject: cmSystemTools: Early return if size makes later comparison false. --- Source/cmSystemTools.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index b07dd78..bb007ef 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -366,6 +366,10 @@ bool cmSystemTools::IsInternallyOn(const char* val) return false; } std::basic_string v = val; + if (v.size() > 4) + { + return false; + } for(std::basic_string::iterator c = v.begin(); c != v.end(); c++) -- cgit v0.12 From d8639733a42149ca1402dcae427f2142ab0cf037 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 27 Jan 2015 23:52:50 +0100 Subject: cmSystemTools: Remove unnecessary comparison. We already know the string is uppercase. --- Source/cmSystemTools.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index bb007ef..d3ab36b 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -376,7 +376,7 @@ bool cmSystemTools::IsInternallyOn(const char* val) { *c = static_cast(toupper(*c)); } - return (v == "I_ON" || v == "i_on"); + return v == "I_ON"; } bool cmSystemTools::IsOn(const char* val) -- cgit v0.12