summaryrefslogtreecommitdiff
path: root/Source/cmCTest.cxx
diff options
context:
space:
mode:
authorMatthias Maennich <matthias@maennich.net>2017-09-19 16:16:25 +0200
committerBrad King <brad.king@kitware.com>2017-09-28 07:23:41 -0400
commit79b8c3802a430577a83ead5b0baab7038a813116 (patch)
tree0343a05c78438d1b43362c254294e5fb241b2b64 /Source/cmCTest.cxx
parenta45928cdebcf37de2605e4f58509a37542dd9eba (diff)
downloadcmake-79b8c3802a430577a83ead5b0baab7038a813116.tar.gz
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/cmCTest.cxx')
-rw-r--r--Source/cmCTest.cxx2
1 files changed, 2 insertions, 0 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index e2482197fd..4ea14931e8 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -969,6 +969,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
}
std::vector<const char*> argv;
+ argv.reserve(args.size() + 1);
for (std::string const& a : args) {
argv.push_back(a.c_str());
}
@@ -2569,6 +2570,7 @@ bool cmCTest::RunCommand(std::vector<std::string> const& args,
const char* dir, double timeout, Encoding encoding)
{
std::vector<const char*> argv;
+ argv.reserve(args.size() + 1);
for (std::string const& a : args) {
argv.push_back(a.c_str());
}