mirror of
https://github.com/godotengine/godot.git
synced 2025-01-18 20:40:57 +08:00
Optimize SWAP
macro by using move semantics.
This commit is contained in:
parent
ba2c5c1e61
commit
383d933f53
@ -43,6 +43,7 @@
|
||||
// Should be available everywhere.
|
||||
#include "core/error/error_list.h"
|
||||
#include <cstdint>
|
||||
#include <utility>
|
||||
|
||||
// Ensure that C++ standard is at least C++17. If on MSVC, also ensures that the `Zc:__cplusplus` flag is present.
|
||||
static_assert(__cplusplus >= 201703L);
|
||||
@ -129,13 +130,7 @@ constexpr auto CLAMP(const T m_a, const T2 m_min, const T3 m_max) {
|
||||
|
||||
// Generic swap template.
|
||||
#ifndef SWAP
|
||||
#define SWAP(m_x, m_y) __swap_tmpl((m_x), (m_y))
|
||||
template <typename T>
|
||||
inline void __swap_tmpl(T &x, T &y) {
|
||||
T aux = x;
|
||||
x = y;
|
||||
y = aux;
|
||||
}
|
||||
#define SWAP(m_x, m_y) std::swap((m_x), (m_y))
|
||||
#endif // SWAP
|
||||
|
||||
/* Functions to handle powers of 2 and shifting. */
|
||||
|
Loading…
Reference in New Issue
Block a user