From f486c3c2f7de2912336a2ffcb5625c28f03e60b8 Mon Sep 17 00:00:00 2001 From: Mihail Isakov Date: Sat, 25 Nov 2023 07:45:17 +0100 Subject: [PATCH] PERF: Fixed COPY_INSTEAD_OF_MOVE in MultiThreaderBase Detected by Coverity 2023.6.2. 330 template 331 ITK_TEMPLATE_EXPORT void 332 ParallelizeImageRegion(const ImageRegion & requestedRegion, 333 TemplatedThreadingFunctorType funcP, 334 ProcessObject * filter) 335 { 336 this->ParallelizeImageRegion( 337 VDimension, 338 requestedRegion.GetIndex().m_InternalArray, 339 requestedRegion.GetSize().m_InternalArray, CID 315595 (1-2 of 2): COPY_INSTEAD_OF_MOVE (COPY_INSTEAD_OF_MOVE)1. copy_constructor_call: funcP is copied in call to copy constructor std::function const &)>, when it could be moved instead. Use std::move(funcP) instead of funcP. 340 [funcP](const IndexValueType index[], const SizeValueType size[]) { 341 ImageRegion region; 342 for (unsigned int d = 0; d < VDimension; ++d) 343 { 344 region.SetIndex(d, index[d]); 345 region.SetSize(d, size[d]); 346 } 347 funcP(region); 348 }, 349 filter); 350 } --- Modules/Core/Common/include/itkMultiThreaderBase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Core/Common/include/itkMultiThreaderBase.h b/Modules/Core/Common/include/itkMultiThreaderBase.h index a0498846e47..4cfdbacc03b 100644 --- a/Modules/Core/Common/include/itkMultiThreaderBase.h +++ b/Modules/Core/Common/include/itkMultiThreaderBase.h @@ -337,7 +337,7 @@ ITK_GCC_PRAGMA_DIAG_POP() VDimension, requestedRegion.GetIndex().m_InternalArray, requestedRegion.GetSize().m_InternalArray, - [funcP](const IndexValueType index[], const SizeValueType size[]) { + [&funcP](const IndexValueType index[], const SizeValueType size[]) { ImageRegion region; for (unsigned int d = 0; d < VDimension; ++d) {