Skip to content

Commit

Permalink
PERF: Use std::move inside itkSetMacro, declare parameter non-const
Browse files Browse the repository at this point in the history
Follows InsightSoftwareConsortium/ITK@e5011ae.
MSVC issued C4114 warnings without it.
  • Loading branch information
Simon Rit authored and SimonRit committed Jul 24, 2023
1 parent 07bcb36 commit d78d777
Showing 1 changed file with 33 additions and 26 deletions.
59 changes: 33 additions & 26 deletions include/rtkFFTRampImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,24 @@

// The Set macro is redefined to clear the current FFT kernel when a parameter
// is modified.
// clang-format off
#undef itkSetMacro
#define itkSetMacro(name, type) \
virtual void Set##name(const type _arg) \
{ \
itkDebugMacro("setting " #name " to " << _arg); \
CLANG_PRAGMA_PUSH \
CLANG_SUPPRESS_Wfloat_equal if (this->m_##name != _arg) \
{ \
this->m_##name = _arg; \
this->Modified(); \
this->m_KernelFFT = nullptr; \
} \
CLANG_PRAGMA_POP \
}
#define itkSetMacro(name, type) \
virtual void Set##name(type _arg) \
{ \
itkDebugMacro("setting " #name " to " << _arg); \
CLANG_PRAGMA_PUSH \
CLANG_SUPPRESS_Wfloat_equal \
if (this->m_##name != _arg) \
{ \
this->m_##name = std::move(_arg); \
this->Modified(); \
this->m_KernelFFT = nullptr; \
} \
CLANG_PRAGMA_POP \
} \
ITK_MACROEND_NOOP_STATEMENT
// clang-format on

namespace rtk
{
Expand Down Expand Up @@ -161,18 +165,21 @@ class ITK_TEMPLATE_EXPORT FFTRampImageFilter
#endif

// Rollback to the original definition of the Set macro
// clang-format off
#undef itkSetMacro
#define itkSetMacro(name, type) \
virtual void Set##name(const type _arg) \
{ \
itkDebugMacro("setting " #name " to " << _arg); \
CLANG_PRAGMA_PUSH \
CLANG_SUPPRESS_Wfloat_equal if (this->m_##name != _arg) \
{ \
this->m_##name = _arg; \
this->Modified(); \
} \
CLANG_PRAGMA_POP \
}

#define itkSetMacro(name, type) \
virtual void Set##name(type _arg) \
{ \
itkDebugMacro("setting " #name " to " << _arg); \
CLANG_PRAGMA_PUSH \
CLANG_SUPPRESS_Wfloat_equal \
if (this->m_##name != _arg) \
{ \
this->m_##name = std::move(_arg); \
this->Modified(); \
} \
CLANG_PRAGMA_POP \
} \
ITK_MACROEND_NOOP_STATEMENT
// clang-format on
#endif

0 comments on commit d78d777

Please sign in to comment.