Skip to content

Commit

Permalink
PERF: Let SetSingleMethod move its first argument (f)
Browse files Browse the repository at this point in the history
The move-constructor of `std::function` is typically faster than its
copy-constructor.
  • Loading branch information
N-Dekker authored and hjmjohnson committed Jan 22, 2024
1 parent 813ddb3 commit 06629c2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Modules/Core/Common/src/itkPlatformMultiThreader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ PlatformMultiThreader::SetNumberOfWorkUnits(ThreadIdType numberOfWorkUnits)
void
PlatformMultiThreader::SetSingleMethod(ThreadFunctionType f, void * data)
{
m_SingleMethod = f;
m_SingleMethod = std::move(f);
m_SingleData = data;
}

Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/src/itkPoolMultiThreader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ PoolMultiThreader::~PoolMultiThreader() = default;
void
PoolMultiThreader::SetSingleMethod(ThreadFunctionType f, void * data)
{
m_SingleMethod = f;
m_SingleMethod = std::move(f);
m_SingleData = data;
}

Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/src/itkTBBMultiThreader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ TBBMultiThreader::~TBBMultiThreader() = default;
void
TBBMultiThreader::SetSingleMethod(ThreadFunctionType f, void * data)
{
m_SingleMethod = f;
m_SingleMethod = std::move(f);
m_SingleData = data;
}

Expand Down

0 comments on commit 06629c2

Please sign in to comment.