diff --git a/lib/base/workqueue.hpp b/lib/base/workqueue.hpp index 8199ec613..fc3711555 100644 --- a/lib/base/workqueue.hpp +++ b/lib/base/workqueue.hpp @@ -67,18 +67,17 @@ public: void Join(bool stop = false); template - void ParallelFor(const VectorType& items, const FuncType& func) + void ParallelFor(VectorType&& items, const FuncType& func) { - ParallelFor(items, true, func); + ParallelFor(std::forward(items), true, func); } - template - void ParallelFor(const VectorType& items, bool preChunk, const FuncType& func) + template>> + void ParallelFor(VectorType&& items, bool preChunk, const FuncType& func) { - using SizeType = decltype(items.size()); - - SizeType totalCount = items.size(); - SizeType chunks = preChunk ? m_ThreadCount : totalCount; + const auto totalCount = std::size(items); + using SizeType = std::remove_const_t; + const auto chunks = preChunk ? m_ThreadCount : totalCount; auto lock = AcquireLock(); @@ -103,7 +102,7 @@ public: offset += count; } - ASSERT(offset == items.size()); + ASSERT(offset == totalCount); } bool IsWorkerThread() const;