diff options
author | Pavel Solodovnikov <hellyeahdominate@gmail.com> | 2017-09-14 13:11:58 (GMT) |
---|---|---|
committer | Pavel Solodovnikov <hellyeahdominate@gmail.com> | 2017-09-14 13:11:58 (GMT) |
commit | 63f6fd144ef0171864ddeccee6618ab179e90384 (patch) | |
tree | 36c602ec8b47cef4b0b72929958c5c19846ffb1e /Source/CTest/cmCTestHG.cxx | |
parent | 420874bfaa20772525c60b20d1ee5b6ef5ed9298 (diff) | |
download | CMake-63f6fd144ef0171864ddeccee6618ab179e90384.zip CMake-63f6fd144ef0171864ddeccee6618ab179e90384.tar.gz CMake-63f6fd144ef0171864ddeccee6618ab179e90384.tar.bz2 |
Meta: modernize old-fashioned loops to range-based `for` (CTest).
Changes done via `clang-tidy` with some manual fine-tuning
for the variable naming and `auto` type deduction
where appropriate.
Diffstat (limited to 'Source/CTest/cmCTestHG.cxx')
-rw-r--r-- | Source/CTest/cmCTestHG.cxx | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx index 7bf5b67..78353b3 100644 --- a/Source/CTest/cmCTestHG.cxx +++ b/Source/CTest/cmCTestHG.cxx @@ -145,9 +145,8 @@ bool cmCTestHG::UpdateImpl() opts = this->CTest->GetCTestConfiguration("HGUpdateOptions"); } std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); - for (std::vector<std::string>::const_iterator ai = args.begin(); - ai != args.end(); ++ai) { - hg_update.push_back(ai->c_str()); + for (std::string const& arg : args) { + hg_update.push_back(arg.c_str()); } // Sentinel argument. @@ -217,25 +216,25 @@ private: this->Rev.Log.assign(&this->CData[0], this->CData.size()); } else if (!this->CData.empty() && name == "files") { std::vector<std::string> paths = this->SplitCData(); - for (unsigned int i = 0; i < paths.size(); ++i) { + for (std::string const& path : paths) { // Updated by default, will be modified using file_adds and // file_dels. this->CurChange = Change('U'); - this->CurChange.Path = paths[i]; + this->CurChange.Path = path; this->Changes.push_back(this->CurChange); } } else if (!this->CData.empty() && name == "file_adds") { std::string added_paths(this->CData.begin(), this->CData.end()); - for (unsigned int i = 0; i < this->Changes.size(); ++i) { - if (added_paths.find(this->Changes[i].Path) != std::string::npos) { - this->Changes[i].Action = 'A'; + for (Change& change : this->Changes) { + if (added_paths.find(change.Path) != std::string::npos) { + change.Action = 'A'; } } } else if (!this->CData.empty() && name == "file_dels") { std::string added_paths(this->CData.begin(), this->CData.end()); - for (unsigned int i = 0; i < this->Changes.size(); ++i) { - if (added_paths.find(this->Changes[i].Path) != std::string::npos) { - this->Changes[i].Action = 'D'; + for (Change& change : this->Changes) { + if (added_paths.find(change.Path) != std::string::npos) { + change.Action = 'D'; } } } @@ -246,9 +245,9 @@ private: { std::vector<std::string> output; std::string currPath; - for (unsigned int i = 0; i < this->CData.size(); ++i) { - if (this->CData[i] != ' ') { - currPath += this->CData[i]; + for (char i : this->CData) { + if (i != ' ') { + currPath += i; } else { output.push_back(currPath); currPath = ""; |