From cf7ba6d43d3096665885e6183595216ffcf93e38 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 31 Jan 2025 11:48:05 -0500 Subject: [PATCH] cmWorkerPool: Convert RunCommand signature to move semantics --- Source/cmWorkerPool.cxx | 17 +++++++++-------- Source/cmWorkerPool.h | 3 +-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/cmWorkerPool.cxx b/Source/cmWorkerPool.cxx index 716499cf72..c057ed1852 100644 --- a/Source/cmWorkerPool.cxx +++ b/Source/cmWorkerPool.cxx @@ -159,7 +159,7 @@ public: // -- Runtime void setup(cmWorkerPool::ProcessResultT* result, bool mergedOutput, - std::vector const& command, + std::vector command, std::string const& workingDirectory = std::string()); bool start(uv_loop_t* uv_loop, std::function finishedCallback); @@ -188,11 +188,11 @@ private: void cmUVReadOnlyProcess::setup(cmWorkerPool::ProcessResultT* result, bool mergedOutput, - std::vector const& command, + std::vector command, std::string const& workingDirectory) { this->Setup_.WorkingDirectory = workingDirectory; - this->Setup_.Command = command; + this->Setup_.Command = std::move(command); this->Setup_.Result = result; this->Setup_.MergedOutput = mergedOutput; } @@ -396,7 +396,7 @@ public: * Run an external process */ bool RunProcess(cmWorkerPool::ProcessResultT& result, - std::vector const& command, + std::vector command, std::string const& workingDirectory); private: @@ -429,7 +429,7 @@ cmWorkerPoolWorker::~cmWorkerPoolWorker() } bool cmWorkerPoolWorker::RunProcess(cmWorkerPool::ProcessResultT& result, - std::vector const& command, + std::vector command, std::string const& workingDirectory) { if (command.empty()) { @@ -439,7 +439,8 @@ bool cmWorkerPoolWorker::RunProcess(cmWorkerPool::ProcessResultT& result, { std::lock_guard lock(this->Proc_.Mutex); this->Proc_.ROP = cm::make_unique(); - this->Proc_.ROP->setup(&result, true, command, workingDirectory); + this->Proc_.ROP->setup(&result, true, std::move(command), + workingDirectory); } // Send asynchronous process start request to libuv loop this->Proc_.Request.send(); @@ -731,12 +732,12 @@ void cmWorkerPoolInternal::Work(unsigned int workerIndex) cmWorkerPool::JobT::~JobT() = default; bool cmWorkerPool::JobT::RunProcess(ProcessResultT& result, - std::vector const& command, + std::vector command, std::string const& workingDirectory) { // Get worker by index auto* worker = this->Pool_->Int_->Workers.at(this->WorkerIndex_).get(); - return worker->RunProcess(result, command, workingDirectory); + return worker->RunProcess(result, std::move(command), workingDirectory); } cmWorkerPool::cmWorkerPool() diff --git a/Source/cmWorkerPool.h b/Source/cmWorkerPool.h index 4035650163..4e7223be2b 100644 --- a/Source/cmWorkerPool.h +++ b/Source/cmWorkerPool.h @@ -102,8 +102,7 @@ public: * Run an external read only process. * Use only during JobT::Process() call! */ - bool RunProcess(ProcessResultT& result, - std::vector const& command, + bool RunProcess(ProcessResultT& result, std::vector command, std::string const& workingDirectory); private: