mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-22 18:17:02 +08:00
Reduce variable scope in swap_byte
Added a specialization to remove the 'if' condition No functional change.
This commit is contained in:
committed by
Marco Costalba
parent
797602938d
commit
b5d10d17c2
@@ -228,10 +228,10 @@ template<typename T, int Half = sizeof(T) / 2, int End = sizeof(T) - 1>
|
|||||||
inline void swap_byte(T& x)
|
inline void swap_byte(T& x)
|
||||||
{
|
{
|
||||||
char tmp, *c = (char*)&x;
|
char tmp, *c = (char*)&x;
|
||||||
if (Half) // Fix a MSVC 2015 warning
|
for (int i = 0; i < Half; ++i)
|
||||||
for (int i = 0; i < Half; ++i)
|
tmp = c[i], c[i] = c[End - i], c[End - i] = tmp;
|
||||||
tmp = c[i], c[i] = c[End - i], c[End - i] = tmp;
|
|
||||||
}
|
}
|
||||||
|
template<> inline void swap_byte<uint8_t, 0, 0>(uint8_t&) {}
|
||||||
|
|
||||||
template<typename T, int LE> T number(void* addr)
|
template<typename T, int LE> T number(void* addr)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user