diff options
author | Matthias Maennich <matthias@maennich.net> | 2017-09-19 14:16:25 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-09-28 11:23:41 (GMT) |
commit | 79b8c3802a430577a83ead5b0baab7038a813116 (patch) | |
tree | 0343a05c78438d1b43362c254294e5fb241b2b64 /Source/CTest | |
parent | a45928cdebcf37de2605e4f58509a37542dd9eba (diff) | |
download | CMake-79b8c3802a430577a83ead5b0baab7038a813116.zip CMake-79b8c3802a430577a83ead5b0baab7038a813116.tar.gz CMake-79b8c3802a430577a83ead5b0baab7038a813116.tar.bz2 |
Improve several occurrences of vector::push_back in loops
Fix issues diagnosed by clang-tidy by pre-allocating the vector capacity
before the loop [performance-inefficient-vector-operation].
Signed-off-by: Matthias Maennich <matthias@maennich.net>
Diffstat (limited to 'Source/CTest')
-rw-r--r-- | Source/CTest/cmCTestBuildHandler.cxx | 1 | ||||
-rw-r--r-- | Source/CTest/cmCTestGIT.cxx | 1 | ||||
-rw-r--r-- | Source/CTest/cmCTestP4.cxx | 1 | ||||
-rw-r--r-- | Source/CTest/cmCTestVC.cxx | 1 |
4 files changed, 4 insertions, 0 deletions
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 1da42d4..f4fc769 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -769,6 +769,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal, } std::vector<const char*> argv; + argv.reserve(args.size() + 1); for (std::string const& arg : args) { argv.push_back(arg.c_str()); } diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 7fe74af..8cb795e 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -214,6 +214,7 @@ bool cmCTestGIT::UpdateByCustom(std::string const& custom) std::vector<std::string> git_custom_command; cmSystemTools::ExpandListArgument(custom, git_custom_command, true); std::vector<char const*> git_custom; + git_custom.reserve(git_custom_command.size() + 1); for (std::string const& i : git_custom_command) { git_custom.push_back(i.c_str()); } diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index 11f6a00..fdf8932 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -464,6 +464,7 @@ bool cmCTestP4::UpdateCustom(const std::string& custom) cmSystemTools::ExpandListArgument(custom, p4_custom_command, true); std::vector<char const*> p4_custom; + p4_custom.reserve(p4_custom_command.size() + 1); for (std::string const& i : p4_custom_command) { p4_custom.push_back(i.c_str()); } diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx index 7e09ef0..fd7f37a 100644 --- a/Source/CTest/cmCTestVC.cxx +++ b/Source/CTest/cmCTestVC.cxx @@ -56,6 +56,7 @@ bool cmCTestVC::InitialCheckout(const char* command) // Construct the initial checkout command line. std::vector<std::string> args = cmSystemTools::ParseArguments(command); std::vector<char const*> vc_co; + vc_co.reserve(args.size() + 1); for (std::string const& arg : args) { vc_co.push_back(arg.c_str()); } |