diff options
author | KUDr <KUDr@openttd.org> | 2007-02-23 20:51:10 +0000 |
---|---|---|
committer | KUDr <KUDr@openttd.org> | 2007-02-23 20:51:10 +0000 |
commit | 8001ab69fbb26b765f0f66858b409f89da74bdf8 (patch) | |
tree | 6dc21c8c3b658f5fb2325b6c1f23ae7184195c99 /src/helpers.hpp | |
parent | c924185f9771d2cbc7078e605bcb6e0e0dd7a079 (diff) | |
download | openttd-8001ab69fbb26b765f0f66858b409f89da74bdf8.tar.xz |
(svn r8864) -Codechange: make ClrBitT(), SetBitT() and ToggleBitT more like CLRBIT() and so on (modify value of the first parameter instead or returning the result)
Diffstat (limited to 'src/helpers.hpp')
-rw-r--r-- | src/helpers.hpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/helpers.hpp b/src/helpers.hpp index 5f378803a..fb5aeb5f8 100644 --- a/src/helpers.hpp +++ b/src/helpers.hpp @@ -138,25 +138,19 @@ template <typename Tenum_t> struct TinyEnumT } }; -template <typename T> FORCEINLINE T ClrBitT(T t, int bit_index) +template <typename T> void ClrBitT(T &t, int bit_index) { - int val = t; - CLRBIT(val, bit_index); - return (T)val; + t = (T)(t & ~((T)1 << bit_index)); } -template <typename T> FORCEINLINE T SetBitT(T t, int bit_index) +template <typename T> void SetBitT(T &t, int bit_index) { - int val = t; - SETBIT(val, bit_index); - return (T)val; + t = (T)(t | ((T)1 << bit_index)); } -template <typename T> FORCEINLINE T ToggleBitT(T t, int bit_index) +template <typename T> void ToggleBitT(T &t, int bit_index) { - int val = t; - TOGGLEBIT(val, bit_index); - return (T)val; + t = (T)(t ^ ((T)1 << bit_index)); } #endif /* HELPERS_HPP */ |