diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-05-23 12:49:54 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2019-05-23 14:19:49 (GMT) |
commit | 006229278b54ee92003100773a0430565fb8fe87 (patch) | |
tree | 04a9927d32bf98df5685fde3b0e5be4811e67f8d /Source/CTest | |
parent | 999516478d56d8604d1413fe3c677a860357516c (diff) | |
download | CMake-006229278b54ee92003100773a0430565fb8fe87.zip CMake-006229278b54ee92003100773a0430565fb8fe87.tar.gz CMake-006229278b54ee92003100773a0430565fb8fe87.tar.bz2 |
Use cmAppend to append ranges to std::vector instances
Diffstat (limited to 'Source/CTest')
-rw-r--r-- | Source/CTest/cmCTestBZR.cxx | 3 | ||||
-rw-r--r-- | Source/CTest/cmCTestBuildHandler.cxx | 3 | ||||
-rw-r--r-- | Source/CTest/cmCTestCoverageHandler.cxx | 16 | ||||
-rw-r--r-- | Source/CTest/cmCTestCurl.cxx | 9 | ||||
-rw-r--r-- | Source/CTest/cmCTestHG.cxx | 3 | ||||
-rw-r--r-- | Source/CTest/cmCTestMultiProcessHandler.cxx | 16 | ||||
-rw-r--r-- | Source/CTest/cmCTestP4.cxx | 5 | ||||
-rw-r--r-- | Source/CTest/cmCTestSVN.cxx | 7 | ||||
-rw-r--r-- | Source/CTest/cmCTestSubmitHandler.cxx | 21 | ||||
-rw-r--r-- | Source/CTest/cmProcess.cxx | 3 |
10 files changed, 35 insertions, 51 deletions
diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx index 83aeb64..b957856 100644 --- a/Source/CTest/cmCTestBZR.cxx +++ b/Source/CTest/cmCTestBZR.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestBZR.h" +#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCTestVC.h" #include "cmProcessTools.h" @@ -242,7 +243,7 @@ private: void CharacterDataHandler(const char* data, int length) override { - this->CData.insert(this->CData.end(), data, data + length); + cmAppend(this->CData, data, data + length); } void EndElement(const std::string& name) override diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 1e17e1c..c8e4fa1 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -978,8 +978,7 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length, if (it != queue->end()) { // Create a contiguous array for the line this->CurrentProcessingLine.clear(); - this->CurrentProcessingLine.insert(this->CurrentProcessingLine.end(), - queue->begin(), it); + cmAppend(this->CurrentProcessingLine, queue->begin(), it); this->CurrentProcessingLine.push_back(0); const char* line = this->CurrentProcessingLine.data(); diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index d76bd2a..f6028c4 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestCoverageHandler.h" +#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmDuration.h" #include "cmGeneratedFileStream.h" @@ -813,15 +814,11 @@ int cmCTestCoverageHandler::HandleJacocoCoverage( // ...and in the binary directory. cmsys::Glob g2; - std::vector<std::string> binFiles; g2.SetRecurse(true); std::string binaryDir = this->CTest->GetCTestConfiguration("BuildDirectory"); std::string binCoverageFile = binaryDir + "/*jacoco.xml"; g2.FindFiles(binCoverageFile); - binFiles = g2.GetFiles(); - if (!binFiles.empty()) { - files.insert(files.end(), binFiles.begin(), binFiles.end()); - } + cmAppend(files, g2.GetFiles()); if (!files.empty()) { cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, @@ -1465,8 +1462,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage( " looking for LCOV files in: " << daGlob << std::endl, this->Quiet); gl.FindFiles(daGlob); // Keep a list of all LCOV files - lcovFiles.insert(lcovFiles.end(), gl.GetFiles().begin(), - gl.GetFiles().end()); + cmAppend(lcovFiles, gl.GetFiles()); for (std::string const& file : lcovFiles) { lcovFile = file; @@ -1604,11 +1600,11 @@ void cmCTestCoverageHandler::FindGCovFiles(std::vector<std::string>& files) std::string daGlob = lm.first; daGlob += "/*.da"; gl.FindFiles(daGlob); - files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end()); + cmAppend(files, gl.GetFiles()); daGlob = lm.first; daGlob += "/*.gcda"; gl.FindFiles(daGlob); - files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end()); + cmAppend(files, gl.GetFiles()); } } @@ -1645,7 +1641,7 @@ bool cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files) "Error while finding files matching " << daGlob << std::endl); return false; } - files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end()); + cmAppend(files, gl.GetFiles()); cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Now searching in: " << daGlob << std::endl, this->Quiet); return true; diff --git a/Source/CTest/cmCTestCurl.cxx b/Source/CTest/cmCTestCurl.cxx index 6eb4354..cc63e45 100644 --- a/Source/CTest/cmCTestCurl.cxx +++ b/Source/CTest/cmCTestCurl.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestCurl.h" +#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCurl.h" #include "cmSystemTools.h" @@ -43,19 +44,15 @@ size_t curlWriteMemoryCallback(void* ptr, size_t size, size_t nmemb, void* data) { int realsize = static_cast<int>(size * nmemb); - - std::vector<char>* vec = static_cast<std::vector<char>*>(data); const char* chPtr = static_cast<char*>(ptr); - vec->insert(vec->end(), chPtr, chPtr + realsize); + cmAppend(*static_cast<std::vector<char>*>(data), chPtr, chPtr + realsize); return realsize; } size_t curlDebugCallback(CURL* /*unused*/, curl_infotype /*unused*/, char* chPtr, size_t size, void* data) { - std::vector<char>* vec = static_cast<std::vector<char>*>(data); - vec->insert(vec->end(), chPtr, chPtr + size); - + cmAppend(*static_cast<std::vector<char>*>(data), chPtr, chPtr + size); return size; } } diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx index 727c59c..ba2252a 100644 --- a/Source/CTest/cmCTestHG.cxx +++ b/Source/CTest/cmCTestHG.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestHG.h" +#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCTestVC.h" #include "cmProcessTools.h" @@ -202,7 +203,7 @@ private: void CharacterDataHandler(const char* data, int length) override { - this->CData.insert(this->CData.end(), data, data + length); + cmAppend(this->CData, data, data + length); } void EndElement(const std::string& name) override diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 477161a..ef63073 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -3,6 +3,7 @@ #include "cmCTestMultiProcessHandler.h" #include "cmAffinity.h" +#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCTestRunTest.h" #include "cmCTestTestHandler.h" @@ -653,13 +654,10 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList() // Reverse iterate over the different dependency levels (deepest first). // Sort tests within each level by COST and append them to the cost list. for (TestSet const& currentSet : cmReverseRange(priorityStack)) { - TestComparator comp(this); - TestList sortedCopy; - - sortedCopy.insert(sortedCopy.end(), currentSet.begin(), currentSet.end()); - - std::stable_sort(sortedCopy.begin(), sortedCopy.end(), comp); + cmAppend(sortedCopy, currentSet); + std::stable_sort(sortedCopy.begin(), sortedCopy.end(), + TestComparator(this)); for (auto const& j : sortedCopy) { if (alreadySortedTests.find(j) == alreadySortedTests.end()) { @@ -688,8 +686,8 @@ void cmCTestMultiProcessHandler::CreateSerialTestCostList() presortedList.push_back(i.first); } - TestComparator comp(this); - std::stable_sort(presortedList.begin(), presortedList.end(), comp); + std::stable_sort(presortedList.begin(), presortedList.end(), + TestComparator(this)); TestSet alreadySortedTests; @@ -992,7 +990,7 @@ static Json::Value DumpCTestInfo( const std::vector<std::string>& args = testRun.GetArguments(); if (!args.empty()) { commandAndArgs.reserve(args.size() + 1); - commandAndArgs.insert(commandAndArgs.end(), args.begin(), args.end()); + cmAppend(commandAndArgs, args); } testInfo["command"] = DumpToJsonArray(commandAndArgs); } diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index aa42810..2eb8dba 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestP4.h" +#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCTestVC.h" #include "cmProcessTools.h" @@ -324,9 +325,7 @@ void cmCTestP4::SetP4Options(std::vector<char const*>& CommandOptions) // The CTEST_P4_OPTIONS variable adds additional Perforce command line // options before the main command std::string opts = this->CTest->GetCTestConfiguration("P4Options"); - std::vector<std::string> args = cmSystemTools::ParseArguments(opts); - - P4Options.insert(P4Options.end(), args.begin(), args.end()); + cmAppend(P4Options, cmSystemTools::ParseArguments(opts)); } CommandOptions.clear(); diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index 04749b7..c834686 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestSVN.h" +#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCTestVC.h" #include "cmProcessTools.h" @@ -269,9 +270,7 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters, std::vector<char const*> args; args.push_back(this->CommandLineTool.c_str()); - - args.insert(args.end(), parameters.begin(), parameters.end()); - + cmAppend(args, parameters); args.push_back("--non-interactive"); std::string userOptions = this->CTest->GetCTestConfiguration("SVNOptions"); @@ -344,7 +343,7 @@ private: void CharacterDataHandler(const char* data, int length) override { - this->CData.insert(this->CData.end(), data, data + length); + cmAppend(this->CData, data, data + length); } void EndElement(const std::string& name) override diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 2b54365..1fa7988 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -63,7 +63,7 @@ private: void CharacterDataHandler(const char* data, int length) override { - this->CurrentValue.insert(this->CurrentValue.end(), data, data + length); + cmAppend(this->CurrentValue, data, data + length); } void EndElement(const std::string& name) override @@ -93,12 +93,9 @@ static size_t cmCTestSubmitHandlerWriteMemoryCallback(void* ptr, size_t size, size_t nmemb, void* data) { int realsize = static_cast<int>(size * nmemb); - - cmCTestSubmitHandlerVectorOfChar* vec = - static_cast<cmCTestSubmitHandlerVectorOfChar*>(data); const char* chPtr = static_cast<char*>(ptr); - vec->insert(vec->end(), chPtr, chPtr + realsize); - + cmAppend(*static_cast<cmCTestSubmitHandlerVectorOfChar*>(data), chPtr, + chPtr + realsize); return realsize; } @@ -107,10 +104,8 @@ static size_t cmCTestSubmitHandlerCurlDebugCallback(CURL* /*unused*/, char* chPtr, size_t size, void* data) { - cmCTestSubmitHandlerVectorOfChar* vec = - static_cast<cmCTestSubmitHandlerVectorOfChar*>(data); - vec->insert(vec->end(), chPtr, chPtr + size); - + cmAppend(*static_cast<cmCTestSubmitHandlerVectorOfChar*>(data), chPtr, + chPtr + size); return size; } @@ -769,8 +764,7 @@ int cmCTestSubmitHandler::ProcessHandler() if (!this->Files.empty()) { // Submit the explicitly selected files: - // - files.insert(files.end(), this->Files.begin(), this->Files.end()); + cmAppend(files, this->Files); } // Add to the list of files to submit from any selected, existing parts: @@ -816,8 +810,7 @@ int cmCTestSubmitHandler::ProcessHandler() } // Submit files from this part. - std::vector<std::string> const& pfiles = this->CTest->GetSubmitFiles(p); - files.insert(files.end(), pfiles.begin(), pfiles.end()); + cmAppend(files, this->CTest->GetSubmitFiles(p)); } // Make sure files are unique, but preserve order. diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx index a2c30bb..7a3b82e 100644 --- a/Source/CTest/cmProcess.cxx +++ b/Source/CTest/cmProcess.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmProcess.h" +#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCTestRunTest.h" #include "cmCTestTestHandler.h" @@ -215,7 +216,7 @@ void cmProcess::OnRead(ssize_t nread, const uv_buf_t* buf) if (nread > 0) { std::string strdata; this->Conv.DecodeText(buf->base, static_cast<size_t>(nread), strdata); - this->Output.insert(this->Output.end(), strdata.begin(), strdata.end()); + cmAppend(this->Output, strdata); while (this->Output.GetLine(line)) { this->Runner.CheckOutput(line); |