diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2011-08-16 05:00:45 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2011-08-16 05:00:45 +0000 |
commit | 34781781278f0fb2557b7c5dd9c0de54ad2aba09 (patch) | |
tree | 0e1f274269d8ac2f80bb73e532721e843b01705d /LUFA/Common/Endianness.h | |
parent | ef4cff29c3cea77d545869ad71bdd043e5475482 (diff) | |
download | lufa-34781781278f0fb2557b7c5dd9c0de54ad2aba09.tar.gz lufa-34781781278f0fb2557b7c5dd9c0de54ad2aba09.tar.bz2 lufa-34781781278f0fb2557b7c5dd9c0de54ad2aba09.zip |
Add shortcuts to SwapEndian_16() and SwapEndian_32() internal functions to improve optimization if called with constant inputs.
Diffstat (limited to 'LUFA/Common/Endianness.h')
-rw-r--r-- | LUFA/Common/Endianness.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/LUFA/Common/Endianness.h b/LUFA/Common/Endianness.h index 123ad425f..e26314975 100644 --- a/LUFA/Common/Endianness.h +++ b/LUFA/Common/Endianness.h @@ -394,6 +394,9 @@ static inline uint16_t SwapEndian_16(const uint16_t Word) ATTR_WARN_UNUSED_RESULT ATTR_CONST; static inline uint16_t SwapEndian_16(const uint16_t Word) { + if (GCC_IS_COMPILE_CONST(Word)) + return SWAPENDIAN_16(Word); + uint8_t Temp; union @@ -420,6 +423,9 @@ static inline uint32_t SwapEndian_32(const uint32_t DWord) ATTR_WARN_UNUSED_RESULT ATTR_CONST; static inline uint32_t SwapEndian_32(const uint32_t DWord) { + if (GCC_IS_COMPILE_CONST(DWord)) + return SWAPENDIAN_32(DWord); + uint8_t Temp; union |