1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

Reduce variable scope in swap_byte

Added a specialization to remove the 'if' condition

No functional change.
This commit is contained in:
Fabian Beuke 2016-11-19 15:55:30 +01:00 committed by Marco Costalba
parent 797602938d
commit b5d10d17c2

View file

@ -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)
{ {