mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53: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:
parent
797602938d
commit
b5d10d17c2
1 changed files with 3 additions and 3 deletions
|
@ -228,10 +228,10 @@ template<typename T, int Half = sizeof(T) / 2, int End = sizeof(T) - 1>
|
|||
inline void swap_byte(T& x)
|
||||
{
|
||||
char tmp, *c = (char*)&x;
|
||||
if (Half) // Fix a MSVC 2015 warning
|
||||
for (int i = 0; i < Half; ++i)
|
||||
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)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue