From 0432b921aecfee3cf400a1f1ad8e65a1f7bc5a01 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 2 Nov 2023 13:56:01 -0400 Subject: cmCTestMultiProcessHandler: Inline removal of pending test as it starts Avoid searching the entire list of ordered pending tests to remove one when we already know where it is. --- Source/CTest/cmCTestMultiProcessHandler.cxx | 17 +++++++---------- Source/CTest/cmCTestMultiProcessHandler.h | 1 - 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index d910367..be210f4 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -438,13 +438,6 @@ void cmCTestMultiProcessHandler::UnlockResources(int index) this->RunningCount -= this->GetProcessorsUsed(index); } -void cmCTestMultiProcessHandler::ErasePendingTest(int test) -{ - this->PendingTests.erase(test); - this->OrderedTests.erase( - std::find(this->OrderedTests.begin(), this->OrderedTests.end(), test)); -} - inline size_t cmCTestMultiProcessHandler::GetProcessorsUsed(int test) { size_t processors = static_cast(this->Properties[test]->Processors); @@ -537,7 +530,8 @@ void cmCTestMultiProcessHandler::StartNextTests() ti != this->OrderedTests.end()) { // Increment the test iterator now because the current list // entry may be deleted below. - int test = *ti++; + auto cti = ti++; + int test = *cti; // We can only start a RUN_SERIAL test if no other tests are also // running. @@ -592,7 +586,8 @@ void cmCTestMultiProcessHandler::StartNextTests() // The test is ready to run. numToStart -= processors; - this->ErasePendingTest(test); + this->OrderedTests.erase(cti); + this->PendingTests.erase(test); this->StartTest(test); } @@ -1411,7 +1406,9 @@ void cmCTestMultiProcessHandler::CheckResume() void cmCTestMultiProcessHandler::RemoveTest(int index) { - this->ErasePendingTest(index); + this->OrderedTests.erase( + std::find(this->OrderedTests.begin(), this->OrderedTests.end(), index)); + this->PendingTests.erase(index); this->Properties.erase(index); this->Completed++; } diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h index ffbe16f..1be04aa 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.h +++ b/Source/CTest/cmCTestMultiProcessHandler.h @@ -127,7 +127,6 @@ protected: // Removes the checkpoint file void MarkFinished(); - void ErasePendingTest(int index); void FinishTestProcess(std::unique_ptr runner, bool started); void StartNextTestsOnIdle(); -- cgit v0.12