diff options
author | Pavel Solodovnikov <hellyeahdominate@gmail.com> | 2017-09-11 10:40:26 (GMT) |
---|---|---|
committer | Pavel Solodovnikov <hellyeahdominate@gmail.com> | 2017-09-12 13:22:47 (GMT) |
commit | 7d5095796ab616cf9b709036387bb95ab9984141 (patch) | |
tree | c010e922adad95ef86ab4a3ac2a3abd63e9f33ef /Source/cmSourceGroupCommand.cxx | |
parent | 00975e926199eea21763470e2ab876246e36669a (diff) | |
download | CMake-7d5095796ab616cf9b709036387bb95ab9984141.zip CMake-7d5095796ab616cf9b709036387bb95ab9984141.tar.gz CMake-7d5095796ab616cf9b709036387bb95ab9984141.tar.bz2 |
Meta: modernize old-fashioned loops to range-based `for`.
Changes done via `clang-tidy` with some manual fine-tuning
for the variable naming and `auto` type deduction
where appropriate.
Diffstat (limited to 'Source/cmSourceGroupCommand.cxx')
-rw-r--r-- | Source/cmSourceGroupCommand.cxx | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index 77fde7b..08a1aa4 100644 --- a/Source/cmSourceGroupCommand.cxx +++ b/Source/cmSourceGroupCommand.cxx @@ -41,8 +41,8 @@ std::set<std::string> getSourceGroupFilesPaths( std::set<std::string> ret; const std::string::size_type rootLength = root.length(); - for (size_t i = 0; i < files.size(); ++i) { - ret.insert(files[i].substr(rootLength + 1)); // +1 to also omnit last '/' + for (std::string const& file : files) { + ret.insert(file.substr(rootLength + 1)); // +1 to also omnit last '/' } return ret; @@ -51,9 +51,9 @@ std::set<std::string> getSourceGroupFilesPaths( bool rootIsPrefix(const std::string& root, const std::vector<std::string>& files, std::string& error) { - for (size_t i = 0; i < files.size(); ++i) { - if (!cmSystemTools::StringStartsWith(files[i], root.c_str())) { - error = "ROOT: " + root + " is not a prefix of file: " + files[i]; + for (std::string const& file : files) { + if (!cmSystemTools::StringStartsWith(file, root.c_str())) { + error = "ROOT: " + root + " is not a prefix of file: " + file; return false; } } @@ -108,14 +108,13 @@ bool addFilesToItsSourceGroups(const std::string& root, { cmSourceGroup* sg; - for (std::set<std::string>::const_iterator it = sgFilesPaths.begin(); - it != sgFilesPaths.end(); ++it) { + for (std::string const& sgFilesPath : sgFilesPaths) { std::vector<std::string> tokenizedPath; if (!prefix.empty()) { - tokenizedPath = tokenizePath(prefix + '/' + *it); + tokenizedPath = tokenizePath(prefix + '/' + sgFilesPath); } else { - tokenizedPath = tokenizePath(*it); + tokenizedPath = tokenizePath(sgFilesPath); } if (tokenizedPath.size() > 1) { @@ -124,10 +123,10 @@ bool addFilesToItsSourceGroups(const std::string& root, sg = addSourceGroup(tokenizedPath, makefile); if (!sg) { - errorMsg = "Could not create source group for file: " + *it; + errorMsg = "Could not create source group for file: " + sgFilesPath; return false; } - const std::string fullPath = getFullFilePath(root, *it); + const std::string fullPath = getFullFilePath(root, sgFilesPath); sg->AddGroupFile(fullPath); } } |