Skip to content

Commit 383d933

Browse files
committed
Optimize SWAP macro by using move semantics.
1 parent ba2c5c1 commit 383d933

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

core/typedefs.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
// Should be available everywhere.
4444
#include "core/error/error_list.h"
4545
#include <cstdint>
46+
#include <utility>
4647

4748
// Ensure that C++ standard is at least C++17. If on MSVC, also ensures that the `Zc:__cplusplus` flag is present.
4849
static_assert(__cplusplus >= 201703L);
@@ -129,13 +130,7 @@ constexpr auto CLAMP(const T m_a, const T2 m_min, const T3 m_max) {
129130

130131
// Generic swap template.
131132
#ifndef SWAP
132-
#define SWAP(m_x, m_y) __swap_tmpl((m_x), (m_y))
133-
template <typename T>
134-
inline void __swap_tmpl(T &x, T &y) {
135-
T aux = x;
136-
x = y;
137-
y = aux;
138-
}
133+
#define SWAP(m_x, m_y) std::swap((m_x), (m_y))
139134
#endif // SWAP
140135

141136
/* Functions to handle powers of 2 and shifting. */

0 commit comments

Comments
 (0)